广州明生医药有限公司


Extjs EditorGridPanel中ComboBox列的显示问题

网络编程 Extjs EditorGridPanel中ComboBox列的显示问题 06-21
为了解决这个问题需要在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使用的store
trackMouseOver: 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: "当前没有记录"
})
});

EXTJS记事本 当CompositeField遇上RowEditor
原因是客户的物料种类非常多,有一千种之多,如果单纯用一个Combobox,那么在实际使用中,很难快速找到一个物料,所以,我使用包含物料分类和物料

ExtJs Excel导出并下载IIS服务器端遇到的问题
项目是Extjs的主要针对于ExtjsGridPanel数据导出这块先做一下说明。我们可以通过Ext.getcmp()方法获取到GridPanel对象并通过重写的方法获取Excel字符串具体方

extjs 初始化checkboxgroup值的代码
Ext.override(Ext.form.CheckboxGroup,{setValueForItem:function(val){//多个选项值以逗号分开的val=","+val+","this.items.each(function(item){if(val.indexOf(item.inputValue)-1){item.setValue(tru


编辑:广州明生医药有限公司

标签:物料,排列,部门,方法,数据