There are one method editGridRow which implement form editing for both "Edit" and "Add" dialogs. So the same event han`ler serializeEditData can be used in both cases. For example,
$("#list").jqGrid('navGrid','#pager',
{/*navGrid options*/},
{/*edit options*/
serializeEditData: function (postdata) {
// your implementation of serializeEditData for edit
}
},
{/*add options*/
serializeEditData: function (postdata) {
// your implementation of serializeEditData for add
}
},
{/*del options*/},
{/*search options*/}
/ );
Typically serializeEditData
event is very practical if you need convert all the posted data in another format, for example to make JSON serialization. To be able to pass extra postdata parameters you can use editData
parameter instead which has the same meaning like postData
parameter of jqGrid:
$("#list").jqGrid('navGrid','#pager',
{/*navGrid options*/},
{/*edit options*/
editData: {SomeExtraData: $('#extradata').val()}
},
{/*add options*/
editData: {SomeExtraData: $('#extradata').val()}
},
{/*del options*/},
{/*search options*/}
);
or better in this way (see this answer about the usage of functions as the property of postData
):
$("#list").jqGrid('navGrid','#pager',
{/*navGrid options*/},
{/*edit options*/
editData: {SomeExtraData: function() {return $('#extradata').val();}}
},
{/*add options*/
editData: {SomeExtraData: function() {return $('#extradata').val();}}
},
{/*del options*/},
{/*search options*/}
);
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…