extjs5学习笔记之combobox

来源:互联网 发布:js div删除class 编辑:程序博客网 时间:2024/06/05 00:34

  由于是demo 直接使用本地数据

var cities = [ {id : 0,name : '城市 0'}, {id : 1,name : '城市 1'}, {id : 2,name : '城市 2'}, {id : 3,name : '城市 3'}, {id : 4,name : '城市 4'} ];

设置如何解析数据

var model = Ext.define('city', { // 数据解析 以后可做成工厂模式 extend :extend : 'Ext.data.Model',idProperty : 'id',fields : [ {  //字段映射name : "cid",type : "int",mapping : 0}, {name : "cname",type : "string",mapping : 1} ]});var store = Ext.create('Ext.data.Store', {model : model,data : cities,/* * proxy : { type : 'ajax', url : url, reader : { type : 'json', } }, //此处可远程加载数据到combobox */autoLoad : true});
最后创建 combbox

return [ {<span style="white-space:pre"></span>//此处若是直接渲染在界面中 应使用new  combobox对象xtype : 'combobox',store : store,triggerAction : "all",displayField : "name",valueField : "id",// pageSize : 5,mode : "local", // or http or remoteemptyText : "请选择湖南城市",// listWidth : 300} ];



0 0
原创粉丝点击