Extjs EditorGridPanel中ComboBox列的显示问题
生活随笔
收集整理的這篇文章主要介紹了
Extjs EditorGridPanel中ComboBox列的显示问题
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
?????? EditorGridPanel中嵌入ComboBox通常不會正常顯示ComboBox的store中本想顯示字段,而是顯示的EditorGridPanel中 store的dataindex指定的字段內容。
?????? 為了解決這個問題需要在EditorGridPanel的ColumnModel中顯示ComboBox的地方使用renderer屬性,重新渲染,方法如下:
//部門列表var comboxDepartmentStore = new Ext.data.Store({proxy: new Ext.data.HttpProxy({url: "GetDepartmentJson.aspx",method: 'GET'}),reader: new Ext.data.JsonReader({root: 'data',totalProperty: 'totalCount',fields: [{ name: 'departmentid', mapping: 'ID' },{ name: 'departmentname', mapping: 'Name' }]})});//根據Combobox列表中對應的Id的值來渲染function rendererMeterTypeCombobox(value, p, r) {var index = comboxDepartmentStore.find(Ext.getCmp('cbdepartment').valueField, value);var record = comboxDepartmentStore.getAt(index);var displayText = "";if (record == null) {return value;} else {return record.data.astype; // 獲取record中的數據集中的display字段的值 }}var sm = new Ext.grid.CheckboxSelectionModel();var cm = new Ext.grid.ColumnModel({columns: [sm, new Ext.grid.RowNumberer(), {header: 'id',dataIndex: 'id',hidden: true}, {header: '姓名',width: 40,dataIndex: 'name'}, {header: '所屬部門',width: 80,dataIndex: 'department',renderer: rendererDepartmentCombobox,editor: new Ext.form.ComboBox({id: "cbdepartment", //必須有 forceSelection: true,selectOnFocus: true,typeAhead: true,triggerAction: 'all',store: comboxDepartmentStore,mode: 'local',displayField: 'departmentname',valueField: 'departmentid',lazyRender: true})}],defaults: {zsortable: true,menuDisabled: false,width: 100}});var editGrid = new Ext.grid.EditorGridPanel({id: 'TestGrid',store: store, //EditorGridPanel使用的storetrackMouseOver: true,disableSelection: false,clicksToEdit: 1, //設置點擊幾次才可編輯loadMask: true,autoHeight: true,cm: cm,sm: sm,viewConfig: {columnsText: '顯示/隱藏列',sortAscText: '正序排列',sortDescText: '倒序排列',forceFit: true,enableRowBody: true},bbar: new Ext.PagingToolbar({pageSize: 25,store: store,displayInfo: true,displayMsg: '當前顯示從{0}至{1}, 共{2}條記錄',emptyMsg: "當前沒有記錄"})});轉載于:https://www.cnblogs.com/jadebug/archive/2011/07/02/2096167.html
總結
以上是生活随笔為你收集整理的Extjs EditorGridPanel中ComboBox列的显示问题的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: [基础|理论|实验]Sizeof与Str
- 下一篇: 笑说房价