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:
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
最满意答案
最简单的解决方案
使用以下符号将符号表达式转换为实际数值函数:
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
的当前值并dtheta
和dpsi
变量。顺便说一句:从不使用变量
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 makesdtheta
anddpsi
variables.By the way: The variable
sdev
is never used.
相关问答
更多-
Matlab问题与功能(Matlab Issue with functions)[2023-05-10]
你使用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.
-
Matlab函数参数问题(Matlab function argument issue)[2023-05-23]
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语句中设置输出值。 可能是这样的: ...