我有多选内联可编辑 jqGrid 和inlineNav
. 以下步骤是创建问题:
- 单击添加按钮,空记录显示在网格中。添加数据并保存。
- 使用复选框选择该记录。
- 按 1 步在网格中添加一条记录,但单击取消按钮而不是保存它。
- 最近的记录消失了,点击编辑按钮,因为我已经选择了一条记录。
- 所选记录未进入编辑模式,它给出警告消息“选择行”。
- 如果我取消选择并再次选择并单击编辑按钮,那么它将以编辑模式出现。
你能告诉我任何解决方案吗?
var i = 1;
var lastSelection = 0;
$(function () {
$("#curruntppeGridgrid").jqGrid({
url: 'getcostperformancecurreuntPPE',
datatype: "json",
jsonReader: { "repeatitems": false, unformat: Unformat_Select },
colNames: ['Category', 'Manufacturer', 'Style', 'UOM', 'Count', 'Unit', 'Qty', 'Cost', 'Sizes', 'Annual Cost', 'VP2'],
colModel: [
{
name: 'category', index: 'category', align: 'center', editable: true, hidden: false, edittype: 'select',
editoptions: {
multiple: false, value: catList,
dataEvents: [{
type: 'change',
fn: function (e) {
loadStyle(e);
}
}]
},
editrules: { required: false, custom: true, custom_func: categorycheck }
},
{
name: 'manufacturer', index: 'manufacturer', align: 'center', editable: true, hidden: false, edittype: 'select',
editoptions: {
value: manufList,
dataEvents: [{
type: 'change',
fn: function (e) {
loadStyle(e);
}
}]
},
editrules: { required: false }
},
{
name: 'style', index: 'style', align: 'center', editable: true, hidden: false, edittype: 'select',
editoptions: {
multiple: false, value: styleList,
dataInit: function (elem) {
var v = $(elem).val();
if (v != '') {
var data = loadSizes(elem);
jQuery('#curruntppeGridgrid').setColProp('sizes', { editoptions: { multiple: true, value: data } });
var data1 = loadUom(elem);
jQuery('#curruntppeGridgrid').setColProp('uom', { editoptions: { value: data1 } });
}
else {
jQuery('#curruntppeGridgrid').setColProp('sizes', { editoptions: { multiple: true, value: {} } });
jQuery('#curruntppeGridgrid').setColProp('uom', { editoptions: { value: {} } });
}
},
dataEvents: [{
type: 'change',
fn: function (e) {
loadCategoryAndManufacturer(e);
}
}]
},
editrules: { required: true }
},
{
name: 'uom', index: 'uom', align: 'center', editable: true, hidden: false, edittype: 'select',
editoptions: {
multiple: false, value: uomfList,
dataEvents: [{
type: 'change',
fn: function (e) {
setHiddenUom(e);
}
}]
},
editrules: { required: false }
},
{
name: 'averagelifetime', index: 'averagelifetime', editable: true, align: 'center', sortable: false, editrules: { number: true, maxValue: 9999999.99 },
editoptions: {
class: 'validate[custom[number]]',
dataEvents: [{
type: 'click',
fn: function (e) {
$('#formQuickSurvey').validationEngine({ promptPosition: 'bottomLeft', validationEventTrigger: 'keyup' });
}
},
{
type: 'change',
fn: function (e) {
setQty(e);
}
}
]
}
},
{
name: 'averagelifetimeselect', index: 'averagelifetimeselect', editable: true, align: 'center', edittype: 'select',
editoptions: {
multiple: false, value: avglifetimelist,
dataInit: function (elem) {
var v = $(elem).val();
if (v != '') {
jQuery('#curruntppeGridgrid').setColProp('averagelifetimeselectId', { editoptions: { defaultValue: v } });
}
},
dataEvents: [{
type: 'change',
fn: function (e) {
setHiddenaveragelifetimeselect(e);
setQty(e);
}
}]
},
editrules: { required: false }
},
{
name: 'qty', index: 'qty', align: 'center', editable: true, editrules: { integer: true, maxValue: 2147483647 },
editoptions: {
class: 'validate[custom[numbersOnly]]',
dataEvents: [{
type: 'change',
fn: function (e) {
calculateannualCost(e);
}
}, {
type: 'click',
fn: function (e) {
$('#formQuickSurvey').validationEngine({ promptPosition: 'bottomLeft', validationEventTrigger: 'keyup' });
}
}]
}
},
{
name: 'cost', index: 'cost', align: 'center', editable: true, editrules: { number: true, maxValue: 9999999.99 },
editoptions: {
class: 'validate[custom[number]]',
dataEvents: [{
type: 'change',
fn: function (e) {
calculateannualCost(e);
}
}, {
type: 'click',
fn: function (e) {
$('#formQuickSurvey').validationEngine({ promptPosition: 'bottomLeft', validationEventTrigger: 'keyup' });
}
}]
}
},
{
name: 'sizes', index: 'sizes', align: 'center', edittype: 'select', classes: 'seteventclickoncurrent', editable: true, editoptions: {
multiple: true, value: {},
dataInit: function (elem) {
var v = $(elem).val();
if (v != '') {
jQuery('#curruntppeGridgrid').setColProp('sizesId', { editoptions: { defaultValue: v } });
}
},
dataEvents: [{
type: 'change',
fn: function (e) {
setHiddensizes(e);
}
}]
},
editrules: { required: false, custom: true, custom_func: checkCurrentSize }
},
{ name: 'annualCost', index: 'annualCost', align: 'center', editable: true, editoptions: { readonly: 'readonly' } },
{
name: 'vp2', index: 'vp2', align: 'center', editable: true, hidden: false, edittype: 'select',
editoptions: {
multiple: false, value: vp2fList,
dataInit: function (elem) {
var v = $(elem).val();
if (v != '') {
jQuery('#curruntppeGridgrid').setColProp('vp2Id', { editoptions: { defaultValue: v } });
}
},
dataEvents: [{
type: 'change',
fn: function (e) {
setHiddenvp2(e);
validateCategoryandVP2(e);
}
}]
},
editrules: { required: false }
}
],
cmTemplate: { sortable: false },
width: eval('gridWidth()'),
pgbuttons: false,
pginput: false,
viewrecords: false,
//pager: '#curruntppeGridpager',
toppager: true,
multiselect: true,
editurl: 'editsurveyppe',
caption: 'Current PPE',
//forceFit:true,
hiddengrid: true,
hidegrid: true,
headertitles: true,
postData: {
appId: function () { return $('#selectApplication option:selected').val(); }
},
loadComplete: function () {
$('#del_curruntppeGridgrid_top').removeClass('ui-state-disabled');//this is added to enable delete button after record reload
if (jQuery('#curruntppeGridgrid').jqGrid('getGridParam', 'gridstate') != 'visible') {
$("#curruntppeGridgrid_toppager").hide();
}
else {
$("#curruntppeGridgrid_toppager").show();
}
},
afterInsertRow: function () {//this is added to disable delete button while adding record
$('#del_curruntppeGridgrid_top').addClass('ui-state-disabled');
}, ajaxSelectOptions: { cache: false }
});
jQuery("#curruntppeGridgrid").jqGrid('navGrid', "#curruntppeGridpager",
{ cloneToTop: true, position: 'right', edit: false, add: false, del: true, search: false, refresh: false, pgbuttons: false },
{}, {}, {
mtype: 'POST', reloadAfterSubmit: true,
serializeDelData: function (postdata) {
var row = jQuery('#curruntppeGridgrid').getRowData(postdata.id);
// append postdata with extra information
return { id: postdata.id, oper: postdata.oper, gridId: 'current' };
}
}, {});
//top toolbar
jQuery("#curruntppeGridgrid").jqGrid('inlineNav', '#curruntppeGridgrid_toppager', {
position: 'right',
editParams: {
aftersavefunc: function () {
$("#curruntppeGridgrid").jqGrid().trigger("reloadGrid");
$('#del_curruntppeGridgrid_top').removeClass('ui-state-disabled');//this is added to enable delete button after saveing record
}, oneditfunc: function () {
$('#del_curruntppeGridgrid_top').addClass('ui-state-disabled');//this is added to disable delete button while editing record
}, afterrestorefunc: function () {
$('#del_curruntppeGridgrid_top').removeClass('ui-state-disabled');//this is added to enable delete button while cancelling record
}, extraparam: {
currentApplicationId: function () { return $("#selectApplication option:selected").val(); }
}
},
"restoreAfterSelect": false
});
jQuery('#curruntppeGridgrid').jqGrid('setGroupHeaders', {
useColSpanStyle: true,
groupHeaders: [{
startColumnName: 'averagelifetime',
numberOfColumns: 2,
titleText: '<em>Average Lifetime</em>'
}]
});
});