extjs 表格编辑,动态显示列怎么弄?
extjs吧
全部回复
仅看楼主
level 1
如图,我想在评分这一列既可以显示文本框,也可以显示下拉框进行评分,怎么弄?它要根据数据集里面另外一列的数据进行判断,求大神指点。代码如下:
/**
* 动态创建测评指标Grid
* tid:教师id,测评人角色在后台采用session获取
*/
function createCpGrid(tid) {
var rec_part = new Ext.data.Record.create([ {
name : *xn*,
type : *string*
}, {
name : *xqmc*,
type : *string*
}, {
name : *xqksrq*,
type : *date*
}, {
name : *xqjsrq*,
type : *date*
} ]);
var store = new Ext.data.Store({
proxy : new Ext.data.HttpProxy({
url : *jskpAction.ered?reqCode=queryKpzbList*
}),
reader : new Ext.data.JsonReader({
totalProperty : *TOTALCOUNT*,
root : *ROOT*
}, [ {
name : *id*
}, {
name : *zid*
}, {
name : *mc*
}, {
name : *max*
}, {
name : *zbsm*
}, {
id : *pffsid*,
name : *pffs*
}])
});
store.load({
params : {
start : 0,
limit : 20,
tid:tid
}
});
store.on(*load*, function() {
});
var pagesize_combo = new Ext.form.ComboBox({
name : *pagesize*,
triggerAction : *all*,
mode : *local*,
store : new Ext.data.ArrayStore({
fields : [ *value*, *text* ],
data : [ [ 10, *10条/页* ], [ 20, *20条/页* ], [ 50, *50条/页* ],
[ 100, *100条/页* ], [ 250, *250条/页* ], [ 500, *500条/页* ] ]
}),
valueField : *value*,
displayField : *text*,
value : *20*,
editable : false,
width : 85
});
var number = parseInt(pagesize_combo.getValue());
pagesize_combo.on("select", function(comboBox) {
bbar.pageSize = parseInt(comboBox.getValue());
number = parseInt(comboBox.getValue());
store.reload({
params : {
start : 0,
limit : bbar.pageSize
}
});
});
var bbar = new Ext.PagingToolbar({
pageSize : number,
store : store,
displayInfo : true,
displayMsg : *显示{0}条到{1}条,共{2}条*,
emptyMsg : "没有符合条件的记录",
items : [ *-*, *  *, pagesize_combo ]
});
//var pffs;
function renderPffs(){
var pffs_edit = new Ext.form.ComboBox( {
hiddenName : *pf*, // 往后台传值字段名
store : new Ext.data.SimpleStore({
fields : [*text*,
*value*],
data : [[*主编*, *1*],
[*参编*, *0*]]
}),
mode : *local*,
triggerAction : *all*,
valueField : *value*,
displayField : *text*,
fieldLabel : *主编*,
emptyText : *请选择...*,
forceSelection : true, // 选中内容必须为下拉列表的子项
editable : true, // 选择输入框可编辑
typeAhead : true, // 输入的时候自动匹配待选项目
anchor : *100%*
});
var pffs_edit1=new Ext.form.TextField({
allowBlank : false,
maxLength : 10
});
for(var i=0;i<store.getCount();i++){
var record=store.gerAt(i);
var pffs=record.get(*pffs*);
if(pffs.equals("1"))
{
return pffs_edit1;
}
else
return pffs_edit;
};
}
// if(pffs.equals("1"))
cm1 = new Ext.grid.ColumnModel( [ new Ext.grid.RowNumberer(), {
id : *id*,
header : *指标编号*,
hidden : true,
dataIndex : *id*
}, {
header : *考核内容*,
dataIndex : *mc*,
sortable : true,
width :450
}, {
header : *最高分*,
dataIndex : *max*,
sortable : true,
width : 60
}, {
header : *评分*,
dataIndex : *pf*,
width : 100,
//renderer:renderPffs,
editor : renderPffs
} ]);
var grid = new Ext.grid.EditorGridPanel({
title : *<span class="commoncss">测评指标</span>*,
height : 500,
autoScroll : true,
region : *center*,
store : store,
loadMask : {
msg : *正在加载表格数据,请稍等...*
},
stripeRows : true,
frame : true,
cm : cm1,
clicksToEdit : 1,// 双击后进入编辑状态
tbar : [ {
text : *刷新*,
iconCls : *arrow_refreshIcon*,
handler : function() {
store.reload();
}
}, *-*, {
text : *单击评分单元格输入分值,输入的分数不能超高最高分*
} ],
bbar : bbar
});
return grid;
}
2014年11月16日 02点11分 1
level 1
顶。
2014年11月16日 17点11分 2
level 3
,
editor:new Ext.form.ComboBox({
allowBlank : false,
displayField:*actionTypeName*,
valueField:*actionTypeValue*,
triggerAction:*all*,
emptyText:*请选择*,
readOnly:true,
store: actionTypeStore
})
加个这个看看
2014年11月17日 08点11分 3
这不就直接加上下拉框吗
2014年11月18日 18点11分
1