我使用自定义表单关注 jqGrid:
jQuery("#list_klanten").jqGrid({
url:'data/relations_select.jsp',
datatype: "json",
colNames:['ID','Klantcode','EAN','Naam','Street','Postal','City','Country','Phone','Status','Cust','Supp','VAT','Language','Currency','','Relationtype','Legal','MotherC','Repr.','Region','Email','Websiote','Faxnr'],
colModel:[
{name:'id',index:'id', width:50,editable:false,editoptions:{size:25}},
{name:'relation_code',index:'relation_code', width:150,editable:true,editoptions:{size:25}},
{name:'ean_code',index:'ean_code', width:150,editable:true,hidden:true,editoptions:{size:25}},
{name:'name',index:'name', width:250,editable:true,editoptions:{size:25}},
{name:'streetname',index:'streetname', width:300,editable:true,sortable:true,editoptions:{size:25}},
{name:'postal_code',index:'postal_code', width:75,editable:true,sortable:true,editoptions:{size:25}},
{name:'city',index:'city', width:200,editable:true,sortable:true,editoptions:{size:25}},
{name:'country',index:'country', width:150,editable:true,sortable:true,editoptions:{size:25}},
{name:'telephone_nr',index:'telephone_nr', width:150,editable:true,hidden:true,editoptions:{size:25}},
{name:'relation_status',index:'relation_status', width:150,editable:true,hidden:true,editoptions:{size:25}},
{name:'customer_flag',index:'customer_flag', width:100,editable:false,search:false,hidden:false,formatter:'checkbox',align:'center',editoptions:{size:25}},
{name:'supplier_flag',index:'supplier_flag', width:100,editable:false,search:false,hidden:false,formatter:'checkbox',align:'center',editoptions:{size:25}},
{name:'vat_nr',index:'vat_nr', width:150,editable:true,hidden:false,editoptions:{size:25}},
{name:'language',index:'language', width:150,editable:true,hidden:false,editoptions:{size:25}},
{name:'currency_code',index:'currency_code', width:150,editable:true,hidden:false,editoptions:{size:25}},
{name:'arrow',index:'arrow', width:50,editable:false,search:false,formatter:linkFormatter},
],
width:1100,
height:600,
rowNum:20,
editurl:'data/relations_edit.jsp',
pager: '#pager_klanten',
viewrecords: true,
caption:"Klanten",
grouping: true,
groupingView : {
groupField : ['currency_code'],
groupColumnShow : [true],
groupText : ['<b>{0}</b>'],
groupCollapse : false,
groupOrder: ['asc'],
groupSummary : [true],
groupDataSorted : false
},
onSelectRow: function(){
var gsr = jQuery("#list_klanten").jqGrid('getGridParam','selrow');
if(gsr){
jQuery("#list_klanten").jqGrid('GridToForm',gsr,"#relation_detail");
} else {
alert("Please select Row")
}
},
});
jQuery("#list_klanten").jqGrid('navGrid','#pager_klanten',{edit:true,add:true,del:true,search:false},{height:400,reloadAfterSubmit:true,closeAfterEdit:true,url:'data/relations_edit.jsp'},{height:400,reloadAfterSubmit:true,closeAfterAdd:true,url:'data/relations_edit.jsp'});
选择一行时,表单填充了选定的值,以便用户可以在此表单中编辑记录。单击保存时,将执行以下代码:
jQuery("#savedata").click(function(){
var rowid = jQuery("#row_id").val();
jQuery("#list_klanten").jqGrid('FormToGrid',rowid,'#relation_detail');
jQuery("#list_klanten").saveRow(rowid,null,'data/relations_edit.jsp');
});
我在网格本身中看到(临时)编辑的值,但实际的“保存”不起作用。当我查看 FireBug 时,我没有看到 data/relations_edit.jsp 被调用...?也没有错误或警告,所以什么都没有发生。我在这里想念什么?
标准编辑选项 - 使用模式弹出窗口进行编辑 - 工作得很好......
非常感谢 !
罗布雷希特