Reputation: 79
need help on sending addtional editURL data to the server. below is my code but it is not working
progGrid.jqGrid({
url : rootURLProgExecList,
editurl : '/ProgGrid.php',
editData : {'action':'weekID','userID':userID},
mtype : "POST",
postData : {'action':'weekID','userID':userID},
datatype : "JSON",
page : 1,
regional : lang,
colNames : progWeekColName[lang],
colModel : [
{ name: 'userID', width: 25, hidden: true },
{ name: 'weekID', key: true, editable: true, width: 20, editrules : { required: true, integer:true, minValue:1} },
],
loadonce : true,
autowidth : true,
height : 445,
rowNum : 20,
caption : progGridCaption,
subGrid : true, // set the subGrid property to true to show expand buttons for each row
subGridRowExpanded : showChildGrid, // javascript function that will take care of showing the child grid
subGridOptions : {
expandOnLoad: false, // expand all rows on load
plusicon : "fa fa-plus-circle",
minusicon : "fa fa-minus-circle"
},
subGridBeforeExpand: function(divid, rowid) {
var expanded = jQuery("td.sgexpanded", "#progGrid")[0];
if(expanded) {
setTimeout(function(){
$(expanded).trigger("click");
}, 100);
}
},
shrinkToFit : true,
sortorder : "asc",
hidegrid : false,
gridview : true,
pgbuttons : false, // disable page control like next, back button
pgtext : null,
viewrecords : true,
recordtext : '{0}-{1} / {2}',
pager : progGridPager
})
.navGrid(progGridPager, {edit: false, add: false, del: false, refresh: true, view: false, search:false})
.inlineNav(progGridPager,{edit: true, add: true, del: true, cancel: true, refresh : true,
editParams: {keys: true},
addParams : {keys: true}});
// the event handler on expanding parent row receives two parameters
// the ID of the grid tow and the primary key of the row subgrid_id
function showChildGrid(parentRowID, parentRowKey) {
var childGridID = parentRowID + "_day";
var childGridPagerID = parentRowKey + "_pager";
// send the parent row primary key to the server so that we know which grid to show
// add a table and pager HTML elements to the parent grid row - we will render the child grid here
$('#' + parentRowID).append('<table id=' + childGridID + '></table><div id=' + childGridPagerID + ' class=scroll></div>');
$("#" + childGridID).jqGrid({
url : rootURLProgExecList,
editurl : '/ProgGrid.php',
editData : {'action':'day', 'userID':userID,'weekID' : parentRowKey},
mtype : "POST",
postData : {'action':'day','userID':userID,'weekID' : parentRowKey},
datatype : "json",
page : 1,
regional : lang,
caption : progWeekCaption[lang],
colNames : progDayColName[lang],
colModel : [
{ name: 'week_ID', width: 75, hidden: true },
{ name: 'dayID', key: true, width: 100, editable:true, editrules : { required: true, integer:true, minValue:1, maxValue:7}, },
],
loadonce : true,
autowidth : true,
//width : 500,
height : '100%',
subGrid : true, // set the subGrid property to true to show expand buttons for each row
subGridRowExpanded: showThirdLevelChildGrid, // javascript function that will take care of showing the child grid
subGridOptions : {
expandOnLoad: false, // expand all rows on load
plusicon: "fa fa-plus-circle",
minusicon: "fa fa-minus-circle"
},
subGridBeforeExpand: function(divid, rowid) {
// #grid is the id of the grid
var expanded = jQuery("td.sgexpanded", "#" + childGridID )[0];
if(expanded) {
setTimeout(function(){
$(expanded).trigger("click");
}, 100);
}
},
shrinkToFit : true,
sortorder : "asc",
hidegrid : true,
gridview : true,
pgbuttons : false, // disable page control like next, back button
pgtext : null,
viewrecords : true,
recordtext : '{0}-{1}/{2}',
pager: '#' + childGridPagerID
})
.navGrid('#' + childGridPagerID, {edit: false, add: false, del: false, refresh: true, view: false, search:false})
.inlineNav('#' + childGridPagerID,{edit: true, add: true, del: true, cancel: true, refresh : true, editParams: {keys: true,}, addParams: {keys: true}});
}
I tried adding the additional data to the addParams and editParams like this addParams: {keys: true,{'action':'weekID','userID':userID}} editParams: {keys: true,{'action':'weekID','userID':userID}} with no luck.
any help would be appreciated
Upvotes: 0
Views: 3568
Reputation: 221997
First of all addParams
option should looks like
addParams: {addRowParams: {keys: true}}
instead of
addParams : {keys: true}
To add more custom data posted to the server during inline editing, like {'action':'weekID','userID':userID}
, you can use to extraparam
:
.navGrid(progGridPager, {edit: false, add: false, del: false, search: false})
.inlineNav(progGridPager, {
editParams: {keys: true, extraparam: {action:'weekID', userID:userID}},
addParams: {addRowParams:{keys:true,extraparam:{action:'weekID',userID:userID}}}});
I see you use Guriddo jqGrid JS. I develop alternative fork of jqGrid: free jqGrid (the current version is 4.12.0). It supports simplified form of providing the options, described in the wiki article. If you would use the options you can reduce your code and simplify it.
I would strictly recommend you additionally to use idPrefix
option at least for subgrids. For example you can use idPrefix: "s_" + parentRowKey + "_"
. It's very important to prevent id duplicates.
Upvotes: 2