广州明生医药有限公司


extjs中grid中嵌入动态combobox的应用

网络编程 extjs中grid中嵌入动态combobox的应用 06-21
拿combobox的数据

comboDS = new Ext.data.JsonStore({
url : 'test.do',
fields : [{
name : 'id'
}, {
name : 'display'
}]
});

combobox定义
combobox 中的id必须要有,后面要跟据id取combobox值。

var comboBox = new Ext.form.ComboBox({
id : "cb", //必须有
typeAhead : true,
readOnly : true,
allowBlank : false,
autoScroll : true,
selectOnFocus : true,
emptyText : '请选择...',
store : comboDS,
forceSelection : true,
triggerAction : 'all',
displayField : 'display',
valueField : 'id'
});

grid 的定义:

ds = new Ext.data.Store({
baseparams : {
start : 0,
limit : RowCount
},
proxy : new Ext.data.HttpProxy({
url :'test2.do'
}),
reader : new Ext.data.JsonReader({
root : 'data',
totalProperty : 'totalCount'
}, [{
name : "bh"
}, {
name : "test"
}]);
});
var cm = new Ext.grid.ColumnModel([new Ext.grid.RowNumberer(), {
header : "编号",
dataIndex : "bh"
}, {
header : "测试",
dataIndex : "test",
renderer : renderer,
editor : comboBox
}]);
grid = new Ext.grid.EditorGridPanel({
title : '测试',
ds : ds,
cm : cm,
clicksToEdit : 1,
viewConfig : {
forceFit : true
},
bbar : new Ext.PagingToolbar({
pageSize : RowCount,
store : ds,
displayInfo : true,
displayMsg : '显示第 {0} 条到 {1} 条记录,一共 {2} 条',
emptyMsg : "没有记录"
})
});

cm 的renderer函数
此方法为解决combobox修改后显示为id

function renderer(value, p, r) {
var index = comboDS.find(Ext.getCmp('cb').valueField, value);
var record = comboDS.getAt(index);
var displayText = "";
if (record == null) {
displayText = value;
} else {
displayText = record.data.display;// 获取record中的数据集中的display字段的值
}

EXT窗口Window及对话框MessageBox
看下面的代码:vari=0;functionnewWin(){varwin=newExt.Window({title:"窗口"+i++,width:400,height:300,maximizable:true});win.show();}Ext.onReady(function(){Ext.get("btn").on("click",newWin);});

EXTJS FORM HIDDEN TEXTFIELD 赋值 使用value不好用的问题
遇到一个很奇怪的问题,ExtJs里的form提交创建的时候从session里取了个操作员的ID,然后在form里添加了一个xtype为hidden的组件,给它写了个value,奇怪的

ExtJS4 组件化编程,动态加载,面向对象,Direct
ExtJS4推荐定义类的时候均使用Ext.define,利用xtype动态加载修改了以前的一个登陆窗口,感觉用官方推荐的方法还是很不错的但还有一些问题没有想得非


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

标签:定义,窗口,组件,加载,测试