我现在从 jqGrid 开始,有一些我无法理解的问题。我正在做一个可内联编辑的网格,但它只是编辑第一行。如果我单击任何行,它只会编辑第一行。我不知道发生了什么,如果有人可以告诉我如何一步一步地做,那将对我有很大帮助。
这是我的代码的一部分:
$(function(){
var lastSel;
$("#list").jqGrid({
url:'php.php',
datatype: 'xml',
mtype: 'POST',
colNames:['ac_n_quad', 'ac_l_circ', 'ac_n_circ', 'ac_fin_g', 'ac_pot', 'ac_volt', 'ac_n_polos', 'ac_t_prot', 'ac_v_prot', 'ac_cabo',
'ac_fd', 'ac_fp', 'ac_ctr', 'ac_pot_a', 'ac_pot_b', 'ac_pot_c', 'ac_pos_1', 'ac_pos_2', 'ac_calc'],
colModel :[
{name:'ac_n_quad', index:'ac_n_quad', width:110, align:'right', editable:true, key:true},
{name:'ac_l_circ', index:'ac_l_circ', width:65, align:'right', editable:true},
{name:'ac_n_circ', index:'ac_n_circ', width:120, align:'right', editable:true, key: true},
{name:'ac_fin_g', index:'ac_fin_g', width:60, align:'right', editable:true},
{name:'ac_pot', index:'ac_pot', width:55, align:'right', editable:true},
{name:'ac_volt', index:'ac_volt', width:60, align:'right', editable:true},
{name:'ac_n_polos', index:'ac_n_polos', width:100, align:'right', editable:true},
{name:'ac_t_prot', index:'ac_t_prot', width:100, align:'right', editable:true},
{name:'ac_v_prot', index:'ac_v_prot', width:70, align:'right', editable:true},
{name:'ac_cabo', index:'ac_cabo', width:60, align:'right', editable:true},
{name:'ac_fd', index:'ac_fd', width:55, align:'right', editable:true},
{name:'ac_fp', index:'ac_fp', width:55, align:'right', editable:true},
{name:'ac_ctr', index:'ac_ctr', width:60, align:'right', editable:true},
{name:'ac_pot_a', index:'ac_pot_a', width:70, align:'right', editable:true},
{name:'ac_pot_b', index:'ac_pot_b', width:70, align:'right', editable:true},
{name:'ac_pot_c', index:'ac_pot_c', width:70, align:'right', editable:true},
{name:'ac_pos_1', index:'ac_pos_1', width:70, align:'right', editable:true},
{name:'ac_pos_2', index:'ac_pos_2', width:70, align:'right', editable:true},
{name:'ac_calc', index:'ac_calc', width:65, align:'right', editable:true}],
cmTemplate: { align: 'center', editable: true },
onSelectRow: function(id){
if(id && id !== lastSel){
$(this).restoreRow(lastSel);
lastSel = id;
}
$(this).editRow (id, true);
},
prmNames: {ac_n_quad: "id"},
editurl:'clientArray',
autowidth: 'true',
height: 'auto',
rowNum: 10,
rowList: [10,20,30, 40, 50, 60, 70, 80, 90, 100],
sortname: 'ac_n_quad, ac_n_circ',
sortorder: 'asc',
pager: '#pager',
viewrecords: true,
gridview: true,
caption: 'Table circ_69'
});
jQuery('#list').jqGrid('gridResize');
jQuery('#list').jqGrid('navGrid', '#pager', {
edit: true,
add: true,
del: true,
search: false,
refresh: false
});
});