jak używać parametru extraParam jqgrid w saveRow
gdzie w jednej komórce typ edycji jest wybierany za pomocą pary wartości klucza, jak poniżej.
<code> colModel: [ {name: 'Code', index: 'Code', width: '16%', editable: true, sortable: true }, { name: 'ABC', index: 'ABC', width: '16%', editable: true, edittype: "select", editoptions: { value: "FE:FedEx;TN:TNT"} }, { name: 'Emailid', index: 'Emailid', width: '16%', editable: true, sortable: true }, ], </code>
Teraz podczas dodawania nowego wiersza, jeśli wybrałemFedEx dlaABC kolumna wyśle FE do EditURL Link nieFedEX więc chcę wysłać FEDEX używając extraParam do EditURL.
Więc proszę, daj mi znać, jak ją wdrożyć.
Do tego mój kod jest poniżej
AKTUALIZOWANY KOD
<code>var grid = jQuery("#list5").jqGrid({ url: '/home1/GetUserData', datatype: "json", mtype: "POST", colNames: ['Code', 'LoginID', 'Emailid'], colModel: [ {name: 'Code', index: 'Code', width: '16%', editable: true, sortable: true }, { name: 'LoginID', index: 'LoginID', width: '16%', editable: true, sortable: true }, { name: 'Emailid', index: 'Emailid', width: '16%', editable: true, edittype: "select", editoptions: { value: "FE:FedEx;TN:TNT"} }, ], rowNum: 10, autowidth: true, height: '100%', rowList: 10, pager: $("#pager2"), editurl: "/home1/EditUserData", onSelectRow: function (id) { if (id && id !== lastsel2) { if (id == "new_row") { grid.setGridParam({ editurl: "/home1/InsertUserData" }); } else { grid.setGridParam({ editurl: "/home1/EditUserData" }); } jQuery('#list5').restoreRow(lastsel2); jQuery('#list5').jqGrid('editRow', id, true, pickdates); $("#list5_ilsave").addClass("ui-state-disabled"); $("#list5_ilcancel").addClass("ui-state-disabled"); $("#list5_iladd").removeClass("ui-state-disabled"); $("#list5_iledit").removeClass("ui-state-disabled"); lastsel2 = id; } }, caption: "Simple data manipulation" }); jQuery("#list5").jqGrid('navGrid', '#pager2', { edit: false, add: false, del: true, search: false, refresh: false }, {}, {}, { url: '/home1/DeleteUserData' }); jQuery('#list5').jqGrid('inlineNav', '#pager2', { edit: true, add: true, editParams: {extraparam: XYZ()}}); }); function XYZ() { // from here i want to return the text of combo of selected row. } </code>
Zaktualizuj kod Olega
<code>var grid = jQuery("#list5"), editingRowId, myEditParam = { keys: true, oneditfunc: function (id) { editingRowId = id; }, afterrestorefunc: function (id) { editingRowId = undefined; }, extraparam: // we get the text of selected option from the column // 'Emailid' and include the data as additional // parameter 'EmailidText' // EmailidText: function () { // return $("#" + editingRowId + "_Emailid>option:selected").text(); //} // **my changes here bind ABC Function which return key , value pair of object** IS THIS POSSIBLE function () { ABC(); } }; grid.jqGrid({ url: '/home1/GetUserData', datatype: "json", ... onSelectRow: function (id) { var $this = $(this), gridIdSelector = '#' + $.jgrid.jqID(this.id); $this.jqGrid('setGridParam', { editurl: (id === "new_row" ? "/home1/InsertUserData" : "/home1/EditUserData") }); if (editingRowId !== id) { $(gridIdSelector + "_iledit").click(); } } }); $grid.jqGrid('navGrid', '#pager', { edit: false, add: false, search: false, refresh: false}, {}, {}, { url: '/home1/DeleteUserData' }); // inlineNav has restoreAfterSelect: true per default so we don't need to call // restoreRow explicitly $grid.jqGrid('inlineNav', '#pager', { edit: true, add: true, editParams: myEditParam, addParams: {addRowParams: myEditParam } }); </code>