首页 \ 问答 \ Sencha触摸列表与模型和商店(Sencha Touch List with Model and Store)

Sencha触摸列表与模型和商店(Sencha Touch List with Model and Store)

我正在寻找带有模型和商店的sencha触摸列表的教程/源代码。 我正在面对Sencha Touch 2.2.1的一些问题。

模型:

Ext.define("DeviceAPIFramework.model.OfferModel", {
    extend: "Ext.data.Model",
    config: {
        fields: [
            { name: "description",  type: "string" },
            { name: "id", type: "string" }
        ]
    }
});

商店:

Ext.define("DeviceAPIFramework.model.OfferStore", {
    extend: "Ext.data.Store",
    config: {
        storeId: "offerStore",
        model:'DeviceAPIFramework.model.OfferModel'
    }
});

控制器:

offerStore.add({description: 'test', id: 'my id'});
Ext.ComponentQuery.query('#offersListHomeView')[0].update();

视图:

Ext.require("DeviceAPIFramework.model.OfferStore");
var offerStore = Ext.create("DeviceAPIFramework.model.OfferStore");

Ext.define ........... 
{
    xtype: 'list',
    width: Ext.os.deviceType == 'Phone' ? null : 1200,
    height: Ext.os.deviceType == 'Phone' ? null : 350,
    title: 'test',
    itemId: 'offersListHomeView',
    store: offerStore,
    itemTpl: '{description} {id}'
}

图片:

列表的图像

从控制器执行代码后,会添加一个新行,但在列表的左上角还会添加一个奇怪的未定义文本。 有任何建议如何解决这个问题?

我也不喜欢视图外的变量offerStore。 如果我把它放在控制器中,视图就会唠叨。


I am looking for a tutorial / sourcecode for a sencha touch list with a model and a store. I am facing some issues with Sencha Touch 2.2.1.

Model:

Ext.define("DeviceAPIFramework.model.OfferModel", {
    extend: "Ext.data.Model",
    config: {
        fields: [
            { name: "description",  type: "string" },
            { name: "id", type: "string" }
        ]
    }
});

Store:

Ext.define("DeviceAPIFramework.model.OfferStore", {
    extend: "Ext.data.Store",
    config: {
        storeId: "offerStore",
        model:'DeviceAPIFramework.model.OfferModel'
    }
});

Controller:

offerStore.add({description: 'test', id: 'my id'});
Ext.ComponentQuery.query('#offersListHomeView')[0].update();

View:

Ext.require("DeviceAPIFramework.model.OfferStore");
var offerStore = Ext.create("DeviceAPIFramework.model.OfferStore");

Ext.define ........... 
{
    xtype: 'list',
    width: Ext.os.deviceType == 'Phone' ? null : 1200,
    height: Ext.os.deviceType == 'Phone' ? null : 350,
    title: 'test',
    itemId: 'offersListHomeView',
    store: offerStore,
    itemTpl: '{description} {id}'
}

Image:

Image of List

After executing the code from the controller, a new row gets appended, but also a weird undefined text on the upper left corner of my list. Any suggestions how to fix this issue?

I also don't like the variable offerStore outside the view. If I put it in the controller, the view is nagging.


原文:https://stackoverflow.com/questions/17498040
更新时间:2023-02-01 16:02

最满意答案

最简单的解决方案

使用以下符号将符号表达式转换为实际数值函数:

fun = matlabFunction((rpar+rperp),'vars',{dtheta,dpsi});

更好的方案:

首先避免使用符号的东西,然后定义一个函数:

function out = YOURFANCYFUNCTION(eta,psi,theta,sdev,dtheta,dpsi)
calpha = (cos(theta+dtheta)).*(cos(psi+dpsi));
rp01 = calpha-sqrt(eta-1+((calpha).^2));
rp02 = calpha+sqrt(eta-1+((calpha).^2));
rperp = (rp01./rp02).^2;
rp11 = ((eta.*calpha)-sqrt(eta-1+((calpha).^2)));
rp12 = ((eta.*calpha)+sqrt(eta-1+((calpha).^2)));
rpar = (rp11./rp12).^2;
out = (rpar+rperp);

传递给积分的函数应该是:

fun = @(dtheta,dpsi) YOURFANCYFUNCTION(eta,psi,theta,sdev,dtheta,dpsi)

它捕获eta,psi,theta,sdev的当前值并dthetadpsi变量。

顺便说一句:从不使用变量sdev


Simplest solution:

Convert the symbolic expression to an actual numerical function using:

fun = matlabFunction((rpar+rperp),'vars',{dtheta,dpsi});

Better solution:

Avoid the symbolic stuff in the first place and just define a function:

function out = YOURFANCYFUNCTION(eta,psi,theta,sdev,dtheta,dpsi)
calpha = (cos(theta+dtheta)).*(cos(psi+dpsi));
rp01 = calpha-sqrt(eta-1+((calpha).^2));
rp02 = calpha+sqrt(eta-1+((calpha).^2));
rperp = (rp01./rp02).^2;
rp11 = ((eta.*calpha)-sqrt(eta-1+((calpha).^2)));
rp12 = ((eta.*calpha)+sqrt(eta-1+((calpha).^2)));
rpar = (rp11./rp12).^2;
out = (rpar+rperp);

The function you pass to integral should then be:

fun = @(dtheta,dpsi) YOURFANCYFUNCTION(eta,psi,theta,sdev,dtheta,dpsi)

Which captures the current values of eta,psi,theta,sdev and makes dtheta and dpsi variables.

By the way: The variable sdev is never used.

相关问答

更多
  • 你使用feval真的过度复杂了,就这么简单: function [ dfx1 ] = derivada_1(x,h ) fh2=funcion(x+h); fh3=funcion(x-h); dfx1=(fh2-fh3)/(2*h); end 原始代码的问题是您没有使用函数句柄。 feval(funcion,x)计算funcion并将返回的值传递给feval,但是funcion需要输入参数。 相反,它应该像feval(@funcion,x)传递一个函数句柄(在其他编程语言中也称为函 ...
  • 小心访问Jython中对象的属性; Jython使用隐式getter / setter,因此从self.x读取会调用self.getX()等等。 在你的jython代码中将所有出现的self.x更改为self._x (同上为y )使它工作(对我而言)。 实际上,Python中的一个惯例是将非公共成员命名为_... Be careful with accessing attributes of an object in Jython; Jython uses implicit getters/setters, ...
  • 最简单的解决方案 使用以下符号将符号表达式转换为实际数值函数: fun = matlabFunction((rpar+rperp),'vars',{dtheta,dpsi}); 更好的方案: 首先避免使用符号的东西,然后定义一个函数: function out = YOURFANCYFUNCTION(eta,psi,theta,sdev,dtheta,dpsi) calpha = (cos(theta+dtheta)).*(cos(psi+dpsi)); rp01 = calpha-sqrt(eta-1+ ...
  • 该开始键仅提及一次,作为couhbase视图的参数 : // View executes a view. // // The ddoc parameter is just the bare name of your design doc without // the "_design/" prefix. // // Parameters are string keys with values that correspond to couchbase // view parameters. Primitive ...
  • 我的Bundle ID和Helper Tool id不匹配并且导致我错误,这是一个愚蠢的错误。 It was a silly mistake that my Bundle ID and Helper Tool id Does not match and that cause me errors.
  • f([1,2,3]) %function call with a single parameter, which is a 3 element vector f(1,2,3) %function call with three parameters f([1,2,3],[1,2,3],[1,2,3]) %function call with three parameters, each a 3 element vector. f([1,2,3]) %function call with a single ...
  • 在尝试了几个小时之后,我发现我必须将JS放在一个函数中并按如下所示启动它。 After trying for several hours, I found that I had to put the JS in a funct ...
  • 根据您的日志,我们有两个来自源目录的文件: 2016-09-28 22:14:34,595 [DEBUG] [org.springframework.integration.file.FileReadingMessageSource] Added to queue: [D:\CSVFiles\MyCustomerTarget_20160928221429.csv, D:\CSVFiles\MyOrderTarget_20160928221429.csv] 也许这会让你感到困惑,因为他们两个都用相同的后缀完 ...
  • uiwait函数仅用于此目的。 只需调用uiwait(f)让matlab等待GUI数字终止。 见doc: uiwait 。 The uiwait function exists for just this purpose. Simply call uiwait(f) to have matlab wait for the GUI figure to terminate. See doc: uiwait.
  • 当你用下面的方式调用函数时: DEMO 0 这隐含地将0作为字符串传递: '0' 。 当您在字符串'0'和0之间执行比较时, '0'将转换为它的ASCII代码( 32 ),并且它总是显示为大于0 。 相反,您将需要使用括号显式调用该函数并传递一个数字。 DEMO(0) 作为一个方面说明,你似乎分配给outvar但是你的函数的输出参数实际上是output 。 此外, 无论条件如何 ,都将outvar指定为底部的1 。 如果您希望为每个条件输出不同的值,则需要在感兴趣的if语句中设置输出值。 可能是这样的: ...

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。