我正在尝试使用包含在. _ 当我尝试添加一些行时,会出现此错误:navGrid
c.p.colModel[e].formoptions is undefined.
当我尝试编辑或删除时,会出现类似的错误。
我正在尝试使用 navGrid 中“包含”的添加、编辑和删除功能。当我尝试添加一些行时,会出现此错误:cpcolModel[e].formoptions 未定义。当我尝试编辑或删除时,会出现类似的错误。有人可以帮我解决这个问题吗?
我的网格代码是:
function mypricecheck(value, colname) {
if (value < 0 || value > 20)
return [false, "Please enter value between 0 and 20"];
else
return [true, ""];
}
$(function () {
var lastSel;
$("#list").jqGrid({
url: "php.php",
datatype: "json",
mtype: "POST",
colNames: ['Index', '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: 'index', index: 'index', width: 65, key: true, hidden: true },
{ name: 'ac_n_quad', index: 'ac_n_quad', width: 110 },
{
name: 'ac_l_circ', index: 'ac_l_circ', width: 65, editable: true, editoptions: {
dataInit: function (elem) {
$(elem).autocomplete({
source: "autocomplete.php?extraparam=ac_l_circ",
select: function (event, ui) {
$(elem).val(ui.item.value);
}
});
}
}
},
{ name: 'ac_n_circ', index: 'ac_n_circ', width: 120, editable: true, editrules: { custom: true, custom_func: mypricecheck } },
{
name: 'ac_fin_g', index: 'ac_fin_g', width: 75, editable: true, editoptions: {
dataInit: function (elem) {
$(elem).autocomplete({
source: "autocomplete.php?extraparam=ac_fin_g",
select: function (event, ui) {
$(elem).val(ui.item.value);
}
});
}
}
},
{ name: 'ac_pot', index: 'ac_pot', width: 55, editable: true, formatter: 'number', formatoptions: { decimalPlaces: 0, thousandsSeparator: '.' } },
{ name: 'ac_volt', index: 'ac_volt', width: 60, editable: true, edittype: "select", formatter: "select", editoptions: { value: "110:110; 220:220" } },
{ name: 'ac_n_polos', index: 'ac_n_polos', width: 100, editable: true, edittype: "select", formatter: "select", editoptions: { value: "1:1; 2:2; 3:3" } },
{ name: 'ac_t_prot', index: 'ac_t_prot', width: 100, editable: true, edittype: "select", formatter: "select", editoptions: { value: "DISJUNTOR:DISJUNTOR; FUSÍVEL:FUSÍVEL" } },
{ name: 'ac_v_prot', index: 'ac_v_prot', width: 70, editable: true },
{
name: 'ac_cabo', index: 'ac_cabo', width: 60, editable: true, editoptions: {
dataInit: function (elem) {
$(elem).autocomplete({
source: "autocomplete.php?extraparam=ac_cabo",
select: function (event, ui) {
$(elem).val(ui.item.value);
}
});
}
}
},
{ name: 'ac_fd', index: 'ac_fd', width: 55, editable: true, formatter: 'number', formatoptions: { decimalPlaces: 1 } },
{ name: 'ac_fp', index: 'ac_fp', width: 55, editable: true, formatter: 'number', formatoptions: { decimalPlaces: 1 } },
{ name: 'ac_ctr', index: 'ac_ctr', width: 60 },
{ name: 'ac_pot_a', index: 'ac_pot_a', width: 70 },
{ name: 'ac_pot_b', index: 'ac_pot_b', width: 70 },
{ name: 'ac_pot_c', index: 'ac_pot_c', width: 70 },
{ name: 'ac_pos_1', index: 'ac_pos_1', width: 70 },
{ name: 'ac_pos_2', index: 'ac_pos_2', width: 70 },
{ name: 'ac_calc', index: 'ac_calc', width: 65 }
],
cmTemplate: { align: "center" },
ondblClickRow: function (id, iRow, iCol, e) {
if (id) {
if (id !== lastSel) {
$("#list").restoreRow(lastSel);
var cm = $("#list").jqGrid('getColProp', 'ac_ctr');
cm.editable = false;
$("#list").editRow(id, true);
$("input, select", e.target).focus().select();
cm.editable = true;
lastSel = id;
} else {
$("#list").restoreRow(lastSel);
lastSel = "";
}
}
},
editurl: "edit.php",
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: "Tabela circ_69"
});
$("#list").jqGrid('navGrid', '#pager', {
add: true,
addtext: "Adicionar",
edit: true,
edittext: "Editar",
del: true,
deltext: "Excluir",
search: false,
refresh: false
},
{
reloadAfterSubmit: true
}, // add options
{
reloadAfterSubmit: true
}, // edit options
{
reloadAfterSubmit: true
} // del options
);
$("#list").jqGrid('gridResize');
});
Firebug 显示错误在 6083 行:
try { nm = g.p.colModel[i].formoptions.label; } catch (e) {}