国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 編程 > JavaScript > 正文

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

2019-11-21 00:00:23
字體:
供稿:網(wǎng)友
拿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 : "沒有記錄"
})
});

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字段的值
}
發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 紫金县| 青龙| 广河县| 张家口市| 龙游县| 保山市| 凤翔县| 兴国县| 大田县| 邹城市| 上饶县| 白城市| 永宁县| 阳东县| 行唐县| 盖州市| 阿拉尔市| 张家界市| 泰兴市| 梓潼县| 固安县| 吉安县| 团风县| 临洮县| 光泽县| 忻城县| 澄城县| 桃园县| 青浦区| 淳化县| 增城市| 安达市| 灯塔市| 砚山县| 临沧市| 平和县| 靖远县| 水城县| 通化县| 萍乡市| 绿春县|