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 无
基础教程推荐
猜你喜欢
- 浅析canvas元素的html尺寸和css尺寸对元素视觉的影响 2024-04-26
- Ajax实现动态加载数据 2023-02-01
- vue离线环境如何安装脚手架vue-cli 2025-01-19
- 关于文字内容过长,导致文本内容超出html 标签宽度的解决方法之自动换行 2023-10-28
- js禁止页面刷新与后退的方法 2024-01-08
- CSS3的几个标签速记(推荐) 2024-04-07
- 浅谈Vue2和Vue3的数据响应 2023-10-08
- 基于Vue制作组织架构树组件 2024-04-08
- JS前端广告拦截实现原理解析 2024-04-22
- this[] 指的是什么内容 讨论 2023-11-30
