sencha touch 访问自定义字段

来源:互联网 发布:域名杂米现在市场价 编辑:程序博客网 时间:2024/06/06 12:20

在sencha touch 里我们会给一些空间添加自定义字段。如下

Ext.define("DingCan.view.category.FoodsList", {extend : 'Ext.DataView',xtype : 'foodslist',requires: ['Ext.SegmentedButton'],config : {title : '菜谱分类',//viewModel就是自定义字段viewModel:'',store : 'foodstore',itemSelector : 'div.node',itemTpl : '<div class="img-desc"><img width="100" height="100" src="{thumbsrc}" alt=""/><cite>{price}元/份</cite>{ordernum}</div>',masked : {xtype : 'loadmask',message : '数据加载中.'}},initialize : function() {//console.log('打印foodlist initial');//console.log(this.viewModel);this.callParent();},beforeInitialize : function() {//this.foodlistEl = this.down('#foodlist');//首先我们需要给自定义字段赋值this.viewModel = 'picModel';}})


然后我们可以通过方法去赋值,注意自定义的字段是通过.访问的。而系统定义的字段需要用.getxxx()方法访问

foodlist.viewModel = ‘picModel’foodlist.getTitle();foodlist.setTitle(123);