欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

extjs中g(shù)rid中嵌入動(dòng)態(tài)combobox的應(yīng)用

 更新時(shí)間:2011年01月01日 18:40:46   作者:  
今天需要在grid中嵌入combobox,在網(wǎng)上找了好久也沒(méi)有找到一個(gè)正確可行的方法,可能是版本問(wèn)題(我版本是extjs 3.0),沒(méi)有繼續(xù)研究其原因,自己查找資料,終于實(shí)現(xiàn)功能?,F(xiàn)在分享一下代碼。
拿combobox的數(shù)據(jù)
復(fù)制代碼 代碼如下:

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

combobox定義
combobox 中的id必須要有,后面要跟據(jù)id取combobox值。
復(fù)制代碼 代碼如下:

var comboBox = new Ext.form.ComboBox({
id : "cb", //必須有
typeAhead : true,
readOnly : true,
allowBlank : false,
autoScroll : true,
selectOnFocus : true,
emptyText : '請(qǐng)選擇...',
store : comboDS,
forceSelection : true,
triggerAction : 'all',
displayField : 'display',
valueField : 'id'
});

grid 的定義:
復(fù)制代碼 代碼如下:

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 : "編號(hào)",
dataIndex : "bh"
}, {
header : "測(cè)試",
dataIndex : "test",
renderer : renderer,
editor : comboBox
}]);
grid = new Ext.grid.EditorGridPanel({
title : '測(cè)試',
ds : ds,
cm : cm,
clicksToEdit : 1,
viewConfig : {
forceFit : true
},
bbar : new Ext.PagingToolbar({
pageSize : RowCount,
store : ds,
displayInfo : true,
displayMsg : '顯示第 {0} 條到 {1} 條記錄,一共 {2} 條',
emptyMsg : "沒(méi)有記錄"
})
});

cm 的renderer函數(shù)
此方法為解決combobox修改后顯示為id
復(fù)制代碼 代碼如下:

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中的數(shù)據(jù)集中的display字段的值
}

相關(guān)文章

最新評(píng)論