EXT4.0模型定义,和数据加载,以及Grid数据绑定的一个小问题,求帮助
时间:2011-12-02
来源:互联网
我有如下Ext模型定义
JScript code
可以看出:UserAccountModel模型有三个一对一关系,即:Header关联一个UserModel模型,MainUser 关联一个UserModel模型,ComInfo关联一个ComInfoModel模型。
我从服务端直接返回了如下格式的JSON数据(全部数据的一部分):
JScript code
Grid绑定方式如下:
JScript code
JScript code
Ext.define('UserModel', { extend: 'Ext.data.Model', idProperty: 'GUID', fields: [ { name: 'GUID', type: 'string' }, { name: 'NickName', type: 'string' }, { name: 'Name', type: 'string' }, { name: 'Cellphone', type: 'string' }, { name: 'UserName', type: 'string' }, { name: 'Sex', type: 'string' }, { name: 'Date', type: 'string' }, { name: 'IsBaseUser', type: 'boolean' }, { name: 'IndexUrl', type: 'string' }, { name: 'AreaName', type: 'string' }, { name: 'AreaId', type: 'string' }, { name: 'Birthday', type: 'string' }, ] }); Ext.define("ComInfoModel", { extend: "Ext.data.Model", idProperty: 'GUID', fields: [ { name: 'GUID', type: 'string' }, { name: 'ComName', type: 'string' }, { name: 'RegName', type: 'string' }, { name: 'ComLogo', type: 'string' }, { name: 'ComSite', type: 'string' }, { name: 'ComUrl', type: 'string' }, { name: 'ComEmail', type: 'boolean' }, { name: 'ComPhone', type: 'string' }, { name: 'BusinessTime', type: 'string' }, { name: 'BusPath', type: 'string' }, { name: 'ComLicenseNo', type: 'boolean' }, { name: 'ComLicensePic', type: 'boolean' }, { name: 'Legal', type: 'string' }, { name: 'LegalIdCard', type: 'string' }, { name: 'LegalPhone', type: 'string' }, { name: 'AboutCom', type: 'string' }, { name: 'PersonCount', type: 'string' }, { name: 'AreaId', type: 'string' }, { name: 'AreaName', type: 'string' }, { name: 'ComAdderss', type: 'string' }, { name: 'IndustryClassId', type: 'string' }, { name: 'IndustryClassName', type: 'string' }, { name: 'Products', type: 'string' }, { name: 'UserAccountId', type: 'string' }, ] }); Ext.define("UserAccountModel", { extend: "Ext.data.Model", idProperty: 'GUID', fields: [ { name: 'GUID', type: 'string' }, { name: 'Level', type: 'number' }, { name: 'CertificationLevel', type: 'number' }, { name: 'OrgType', type: 'number' }, { name: 'Tags', type: 'string' } ], hasMany: [ { name: 'Header', model: 'UserModel' }, { name: 'MainUser', model: 'UserModel' }, { name: 'ComInfo', model: 'ComInfoModel' } ] });
可以看出:UserAccountModel模型有三个一对一关系,即:Header关联一个UserModel模型,MainUser 关联一个UserModel模型,ComInfo关联一个ComInfoModel模型。
我从服务端直接返回了如下格式的JSON数据(全部数据的一部分):
JScript code
{ "DataCount":30, "Data":[{ "GUID":"f8efb990-f215-4da2-aa82-073071209c2a", "Level":0, "CertificationLevel":0, "Header":null, "MainUser":{ "GUID":"edfc6736-17e8-4006-86bb-ceaf3eeeb9f7", "NickName":"", "Name":null, "Cellphone":null, "UserName":"", "TimeKey":"20110902113051609", "Password":"", "QuestionOne":null, "QuestionTwo":null, "QuestionThree":null, "AnswerOne":null, "AnswerTwo":null, "AnswerThree":null, "Sex":0, "ImAccount":null, "ImType":0, "UserFace":null, "AccountState":0, "IsShow":true, "Tags":null, "Date":"\/Date(1314934251000)\/", "IsBaseUser":true, "IndexUrl":"dgjiecheng", "Info":null, "AreaId":"", "AreaName":"", "AreaDetail":null, "RegisteredAreaId":null, "RegisteredAreaName":null, "Birthday":"\/Date(1314934251000)\/", "WorkDate":"\/Date(1314934251000)\/"}, "OrgType":1, "Tags":null }, "ComInfo":{ "ComName":"", "RegName":null, "ComLogo":"b7c66e996b1346afb04fe8e6fbefa7a1_20110902.jpg", "ComSite":"", "ComUrl":"dgjiecheng", "ComEmail":null, "ComPhone": "0769-21395765", "BusinessTime":null, "BusPath":null, "ComLicenseNo":null, "ComLicensePic":"e6b89ee74bc8441782dcbc4a06591fb8_20110902.jpg", "Legal":"", "LegalIdCard":null, "LegalPhone":null, "AboutCom":"", "PersonCount":"50-150人", "AreaId":"", "AreaName":"", "ComAdderss":null, "IndustryClassId":"3091676d-bce9-4be0-aba4-430909680ba1", "IndustryClassName":"", "Products":null, "UserAccountId":"f8efb990-f215-4da2-aa82-073071209c2a" } } ]}
Grid绑定方式如下:
JScript code
var AccountStore = new Ext.data.JsonStore({ autoDestroy: true, storeId: 'AccountStore', model: 'UserAccountModel', autoLoad: true, pageSize: 20, proxy: { type: 'ajax', url: '/Account/GetList', actionMethods: "POST", reader: { type: 'json', root: 'Data', totalProperty: 'DataCount' } } }); var grid = Ext.create('Ext.grid.Panel', { renderTo: Ext.getBody(), store: AccountStore, selModel: Ext.create('Ext.selection.CheckboxModel'), columns: [{ header: '类型', dataIndex: 'OrgType', }, { header: '名称', dataIndex: 'ComName'//[color=#FF0000]问题在这里(您看到的这种方式无效),我如何绑定ComInfo中的ComName属性?[/color] } ]
作者: nozeryu 发布时间: 2011-12-02

没人回答么?着急啊。
作者: nozeryu 发布时间: 2011-12-02
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28