首页 \ 问答 \ Sencha Touch,setRecord()不起作用。(Sencha Touch, setRecord() not working. Fields are blank.)

Sencha Touch,setRecord()不起作用。(Sencha Touch, setRecord() not working. Fields are blank.)

我是Sencha Touch的新手......

我一直在搜索并询问人们几个小时,但无法弄清楚为什么我的详细信息视图无法获取数据(使用setRecord)。

我还没有找到一个使用Ext.NavigationView来推送使用setRecord数据的视图的例子,所以我怀疑我在那里做错了什么。

我有一个标签视图。 第一个选项卡显示项目列表。 单击项目披露以查看该项目的详细信息。 出现详细视图,但没有任何数据。

  • 选项卡在ViewPortController的启动功能中设置。
  • 第一个选项卡中的主视图是PeopleListView。 所有人都出现在列表中。
  • PeopleListView被添加到Ext.NavigationView。 Ext.NavigationView的引用被添加到PeopleListView,以便以后使用
  • PeopleListViewController有一个函数showDetailView,当点击一个公开按钮时,它成功调用。
  • 控制器的showDetailView功能
    • 在personDetailView上设置记录(包含正确的数据),
    • 检索Ext.NavigationView的实例并推送PersonDetailView。
  • 传递给showDetailView的记录值具有正确的数据。
  • 当personDetailView出现时,字段没有数据。

ViewPortController:

launch: function() {
    // var personDetailView = {
    //    xtype: 'persondetailview'
    // }
    var pplView = Ext.create('PeopleApp.view.PeopleListView');
    var pplNavView = Ext.create('Ext.NavigationView', {
        title: 'People',
        iconCls: 'home',
        useTitleForBackButtonText: true,
    });
    pplView.setNavigationView(pplNavView);
    pplNavView.add(pplView);
    . . .
    var mainViewPort = getMainViewPort();
    mainViewPort.setItems([pplNavView, . . .]);
}, 

PersonModel:

Ext.define('PeopleApp.model.PersonModel', {
extend: 'Ext.data.Model',
requires: ['Ext.data.proxy.Rest'],
config: {
    idProperty: 'id',
    fields: [
        { name: 'id',       type: 'auto'   },
        { name: 'name',     type: 'string' },
        { name: 'address',  type: 'string' },
        { name: 'email',    type: 'string' },
        { name: 'age',      type: 'int'    },
        { name: 'gender',   type: 'string' },
        { name: 'note',     type: 'string' }
    ],
    proxy: {
        type: 'rest',
        url: '/app/data/people.json',
        reader: {
            type: 'json',
            rootProperty: 'people'
        }
    },
}
});

PeopleListViewController:

Ext.define('PeopleApp.controller.PeopleListViewController', {
extend: 'Ext.app.Controller',
xtype: 'peoplelistviewcontroller',
config: {
    refs: {
        peopleListView: 'peoplelistview',
        personDetailView: 'persondetailview',
        peopleView: 'peopleview',
    },
    control: {
        peopleListView: {
            discloseDetail: 'showDetailView'
        }
    }
},

showDetailView: function(view, record) {
    console.log("record.data.name=" + record.data.name);

    var detailView = Ext.create('PeopleApp.view.PersonDetailView');
    //var detailView = this.getPersonDetailView();
    detailView.setRecord(record);
    var navView = view.getNavigationView();
    navView.push(detailView);
},

launch: function() { this.callParent(arguments); },
init: function() { this.callParent(arguments); },
});

PersonDetailView:

Ext.define('PeopleApp.view.PersonDetailView', {
extend: 'PeopleApp.view.BaseView',
xtype: 'persondetailview',
requires: [
    'Ext.form.FieldSet',
    'Ext.form.Text',
    'Ext.form.TextArea'
],
config: {
    title: "Person Details",
    scrollable: true,
    items: [{
        xtype: 'fieldset',
        items: [{
                xtype: 'textfield',
                name: 'name',
                label: 'Name: ',
                required: true
            }, {
                xtype: 'textfield',
                name: 'age',
                label: 'Age: ',
                required: false
            }, // etc.
        ]}
    ]}
});

你能告诉我为什么detailView.setRecord(record)没有得到DetailViewController领域的数据集,我需要做些什么呢?


I'm new to Sencha Touch...

I've been searching and asking people for hours, but cannot figure out why my detail view does not get the data (using setRecord).

I have not been able to find an example that uses Ext.NavigationView to push a view that uses the data from setRecord, so I suspect I'm doing something wrong there.

I have a tabbed view. First tab shows a list of items. Click an item disclosure to see details for that item. The detail view appears, but with no any data.

  • The tabs are setup in the launch function of ViewPortController.
  • The main view in the first tab is the PeopleListView. All the people appear in the list.
  • The PeopleListView is added to an Ext.NavigationView. A reference to the Ext.NavigationView is added to the PeopleListView so it can be used later
  • PeopleListViewController has a function, showDetailView, that is successfully called when a disclosure button is tapped.
  • The controller's showDetailView function
    • sets the record (which contains the correct data) on the personDetailView,
    • retrieves the instance of the Ext.NavigationView and pushes the PersonDetailView.
  • The record value passed to showDetailView has the correct data.
  • When personDetailView appears, the fields have no data.

ViewPortController:

launch: function() {
    // var personDetailView = {
    //    xtype: 'persondetailview'
    // }
    var pplView = Ext.create('PeopleApp.view.PeopleListView');
    var pplNavView = Ext.create('Ext.NavigationView', {
        title: 'People',
        iconCls: 'home',
        useTitleForBackButtonText: true,
    });
    pplView.setNavigationView(pplNavView);
    pplNavView.add(pplView);
    . . .
    var mainViewPort = getMainViewPort();
    mainViewPort.setItems([pplNavView, . . .]);
}, 

PersonModel:

Ext.define('PeopleApp.model.PersonModel', {
extend: 'Ext.data.Model',
requires: ['Ext.data.proxy.Rest'],
config: {
    idProperty: 'id',
    fields: [
        { name: 'id',       type: 'auto'   },
        { name: 'name',     type: 'string' },
        { name: 'address',  type: 'string' },
        { name: 'email',    type: 'string' },
        { name: 'age',      type: 'int'    },
        { name: 'gender',   type: 'string' },
        { name: 'note',     type: 'string' }
    ],
    proxy: {
        type: 'rest',
        url: '/app/data/people.json',
        reader: {
            type: 'json',
            rootProperty: 'people'
        }
    },
}
});

PeopleListViewController:

Ext.define('PeopleApp.controller.PeopleListViewController', {
extend: 'Ext.app.Controller',
xtype: 'peoplelistviewcontroller',
config: {
    refs: {
        peopleListView: 'peoplelistview',
        personDetailView: 'persondetailview',
        peopleView: 'peopleview',
    },
    control: {
        peopleListView: {
            discloseDetail: 'showDetailView'
        }
    }
},

showDetailView: function(view, record) {
    console.log("record.data.name=" + record.data.name);

    var detailView = Ext.create('PeopleApp.view.PersonDetailView');
    //var detailView = this.getPersonDetailView();
    detailView.setRecord(record);
    var navView = view.getNavigationView();
    navView.push(detailView);
},

launch: function() { this.callParent(arguments); },
init: function() { this.callParent(arguments); },
});

PersonDetailView:

Ext.define('PeopleApp.view.PersonDetailView', {
extend: 'PeopleApp.view.BaseView',
xtype: 'persondetailview',
requires: [
    'Ext.form.FieldSet',
    'Ext.form.Text',
    'Ext.form.TextArea'
],
config: {
    title: "Person Details",
    scrollable: true,
    items: [{
        xtype: 'fieldset',
        items: [{
                xtype: 'textfield',
                name: 'name',
                label: 'Name: ',
                required: true
            }, {
                xtype: 'textfield',
                name: 'age',
                label: 'Age: ',
                required: false
            }, // etc.
        ]}
    ]}
});

Can you tell me why detailView.setRecord(record) does not get the data set in the fields of DetailViewController, and what I need to do differently?


原文:https://stackoverflow.com/questions/29504030
更新时间:2023-08-11 16:08

最满意答案

对于大型数据集,懒惰评估不应该更快,它只会推迟评估,直到需要该值为止。 例如,如果你输入你的ghci

fromRange (< 50) (1, 1000000000)

在遍历整个列表之前,您必须等待一段时间,然后将其过滤并打印结果。

另一方面:

take 10 $ fromRange (< 50) (1, 1000000000)

将立即完成,因为它不必计算列表的其余部分。

注意:因为它不会找到足够的条目,所以take 100也会挂起。


Lazy evaluation is not supposed to be faster for large datasets, it only postpones the evaluation until the very moment when the value is needed. For example, if you type in your ghci:

fromRange (< 50) (1, 1000000000)

you'll have to wait forever before it iterates through the whole list to filter it and print the result.

On the other hand:

take 10 $ fromRange (< 50) (1, 1000000000)

will complete instantly, because it does not have to calculate the rest of the list.

Note: take 100 will hang as well, since it won't ever find enough entries.

相关问答

更多
  • 首先,注意你们两个版本之间的差异是定量的,而不是定性的。 第一个将在输入40000000上堆栈溢出,第二个将在10000000的输入上成功完成。 看起来第二个版本使用的堆栈数量是第一个版本的两倍。 基本上,原因是,如果我们为生活在x和y参数中的thunk引入记法{n} ,那么您的第一个版本会 fib2 {n} {n+1} 0 = {n} fib2 {n} {n+1} z = let {n+2} = (+) {n} {n+1} -- build a thunk i ...
  • 懒惰评估可以替代宏的某些用途(那些延迟评估来创建控制结构的),但是相反的并不是真的。 您可以使用宏来延迟评估结构的透明度 - 请参阅SRFI 41(Streams)以获得如下示例: http : //download.plt-scheme.org/doc/4.1.5/html/srfi-std/srfi -41 / SRFI-41.html 此外,您还可以编写自己的懒惰IO原语。 然而,在我的经验中,严格语言中的普遍的懒惰代码往往会引入一个开销,相比之下,在运行时的普遍的懒惰代码,旨在从一开始就有效地支持它 ...
  • 主要是因为它可以更有效 - 如果不使用它们,则不需要计算值。 例如,我可以将三个值传递给一个函数,但是根据条件表达式的顺序,实际上只能使用一个子集。 在C语言中,所有三个值都将被计算出来; 但是在Haskell中,只计算必要的值。 它还允许像无限列表一样的酷的东西。 我不能在C语言中有无限列表,但是在Haskell中,这没有问题。 无数列表在数学的某些领域相当频繁地使用,所以有能力操纵它们。 Mostly because it can be more efficient -- values don't ne ...
  • 你是对的,在显示图像内容之前,实际上并没有计算出图像内容。 如果需要提前计算,可以使用freeze将图像转换为位图。 在您的示例中,尝试将flipped的定义更改为以下内容: (define flipped (map (compose1 freeze flip-horizontal) images)) You're right that the image content isn't actually computed until it's time to display it. You can use ...
  • 对于大型数据集,懒惰评估不应该更快,它只会推迟评估,直到需要该值为止。 例如,如果你输入你的ghci : fromRange (< 50) (1, 1000000000) 在遍历整个列表之前,您必须等待一段时间,然后将其过滤并打印结果。 另一方面: take 10 $ fromRange (< 50) (1, 1000000000) 将立即完成,因为它不必计算列表的其余部分。 注意:因为它不会找到足够的条目,所以take 100也会挂起。 Lazy evaluation is not supposed ...
  • 这段代码中没有任何内容本身就是懒惰的 - 它应该以正确的顺序执行。 但是,根据a和b的内容,可能会在其中嵌入一些懒惰的东西,只有在执行(println a)和(println b)才会执行。 特别是,如果a和b是使用map或类似的东西创建的延迟序列,那么只有在println语句中强制执行时才会评估序列的后面部分。 更具体地说,你需要描述a和b的内部结构。 我实际上怀疑问题可能是由于缓冲区没有被冲洗 - 请参阅Clojure - 副作用发生故障 Nothing in this code is inherent ...
  • 这是关键: 可组合性 arr.stream() .filter(Lazy::isGreater) .filter(Lazy::isEven) .map(Lazy::doubleIt) .findFirst(); 这似乎是无害的,但现在这是一个价值: arr.stream() .filter(Lazy::isGreater) 您可以将其交给方法并在其上构建。 什么可以用等效的循环? 您可以在任何地方使用它进行复制粘贴。 它不是一个可组 ...
  • 据我所知,在Matlab中没有更好的方法来实现这一点, 这里也有建议 。 请记住,Matlab不会检测同一术语的多个评估。 如果你做的事情如下: foo = @() 1+1 bar=@()foo()*foo() 它将评估foo两次。 相反,“传统”方式将评估一次: foo=1+1 bar=foo+foo To my knowledge there is no better way to achieve this in Matlab, it's also suggested here. Just keep ...
  • 它太懒了,甚至没有做好工作 - 可能是因为你实际上没有使用操作的结果。 在那里放一个sleep()来确认: > Benchmark.bm do |rep| rep.report('lazy') { num.times do ; arr.lazy.map { |x| sleep(5) }; end } rep.report('notlazy') { 1.times do ; [0,1].map { |x| sleep(5) } ; end } end us ...
  • if和cond不是“懒惰”,他们只是有不同的评估规则。 例如,在下面的表达式中,只执行if的后续部分,因为条件恰好为true : (if (= 1 1) 'ok (/ 1 0)) => 'ok 如果替代部分被执行,我们将有零错误除法。 这不是懒惰的评估,它只是if表达式在Scheme中的工作方式。 将上面的示例与此示例进行比较: (define (my-if condition consequent alternative) (if condition consequent ...

相关文章

更多

最新问答

更多
  • 获取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的基本操作命令。。。