强大的JQuery的插件jqGrid(6)
时间:2025-06-09
时间:2025-06-09
希望这个帮助文档能对大家学习jQuery的插件jqGrid带来帮助(在个人的使用过程中不断更新),希望大家提出意见。
var arr = text.split(";");
if(arr[0].indexOf("true")!=-1){
var num = parseFloat(arr[1]);
jQuery("#list").setCell(rowid,"N_JinEr",num ,{color:'red','text-align':'center'});
}
},
以上代码展示了cellEdit设置需要的代码。cellEdit功能的实现只需要设置cellEdit为true,并设置cellurl在后台写处理数据的程序即可。而要满足功能上的需要,还需要添加afterEditCell等事件。
afterSubmitCell:提交完成后事件,serverrepsponse从后台返回数据,rowid选中行id, cellname 单元格name属性在colModel里设置,value cell的值,iRow index of the row,iCol the index of the column
jQuery("#list").setCell(rowid,"N_JinEr",num ,{color:'red','text-align':'center'}//设行id为rowid,列名为’N_JinEr’的单元格值为num,样式设置为{color:'red','text-align':'center'}。
afterSubmitCell处理了cellEdit编辑后,从后台取回数据并处理单元格值的过程,在实际情况下根据需要添加不同事件即可。
(二) inlineEdit:
editurl:pathname+'/xmlTableEdit?openagent&oper='+oper+'&showView='+showView+'&formName='+formName+'&punid='+unid, //设置添加、更新的url /* //以下参数根据需要添加, /* oper: 操作类型,edit 编辑、 del 删除、
showView: 操作视图名,即表格展示的试图
formName: 操作标识符,区分不同表单的不同操作
punid: 主文档id
*/
ultiselect: false, //选择行属性inlineEdit时不能设置多选行
onSelectRow: function(id){
chooseid=id;
if(id && id!==lastsel2){
jQuery('#list').restoreRow(lastsel2); //选中不同表格id变化 jQuery('#list').editRow(id,true,oneditfunc,aftersavefunc); //表格编辑函数
lastsel2=id;
};
// 表格编辑时触发函数,一般无用可以为空
function oneditfunc(id){
};
//格编辑保存后执行函数,可以用来处理相关事件
function aftersavefunc(id,res){
jQuery("#list").trigger("reloadGrid");
changeValueafEdit(showView,unid);
};
},
// 重写编辑验证提示
上一篇:初中美术教学计划
下一篇:重庆经济发展现状与未来[1]