ExtJS, SenchaTouch - FormPanel can't load values from a store?如何将值从商店加载到表单面板中?我在这里构建了一个完整的示例。我不确定为什么我的表单...
如何将值从商店加载到表单面板中?我在这里构建了一个完整的示例。
我不确定为什么我的表单域没有加载。
型号:
1 2 3 4 5 6 7 8 9 | Ext.ns('app', 'app.defaults'); Ext.regModel('MyModel', { fields: [ {name: 'var1', type: 'integer'} ] }); app.defaults.vars = { var1: 5 }; |
店铺:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | var myStore = new Ext.data.Store({ model: 'MyModel', proxy: { type: 'localstorage', id: 'model-proxy' }, listeners: { load: function(store, records, successful) { if (this.getCount() > 1) { alert('Error: More than one record is impossible.'); this.proxy.clear(); } if (this.getCount() == 0) { alert("Count 0, loading defaults"); this.add(app.defaults.vars); this.sync(); } console.log("Attempting to load store"); myForm.load(this); } }, autoLoad: true, autoSave: true }); |
形式:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | var myForm = new Ext.form.FormPanel({ id: 'my-form', scroll: 'vertical', items: [ { xtype: 'fieldset', defaults: { labelWidth: '35%' }, items: [ { xtype: 'numberfield', id: 'var1', name: 'var1', label: 'Var1', placeHolder: '100', useClearIcon: true } ] } ] }); |
相关讨论
我找到了其他方式将表单面板与数据连接起来
加载表单后插入以下代码
1 2 3 | myForm.getForm().loadRecord(Ext.ModelManager.create({ 'var1':5 }, 'MyModel')); |
那么,加载记录而不是存储。加载
相关讨论
织梦狗教程
本文标题为:关于 sencha touch:ExtJS、SenchaTouch – FormPanel 无


基础教程推荐
猜你喜欢
- Unicode中的常用字母小结 2022-09-21
- 解决:layUI数据表格+简单查询 2022-12-16
- JavaScript垃圾回收机制(引用计数,标记清除,性能优 2022-08-31
- 关于ajax异步访问数据的问题 2023-02-23
- 纯javascript的ajax实现php异步提交表单的简单实例 2022-12-28
- ajax实现数据分页查询 2023-01-31
- Ajax提交表单并接收json实例代码 2023-02-13
- 在IE中为abbr标签加样式 2022-10-16
- AJax 把拿到的后台数据在页面中渲染的实例 2023-02-22
- 原生ajax瀑布流demo分享(必看篇) 2023-02-01