JqGridInlineNavigatorAddActionOptions pass master rowId

Sep 24, 2013 at 7:01 AM
Hi Tomasz,

Need to know/pass the master (parent) key in order to insert a child/detail record correctly, so something like Url = Url.Action("InsertDetail", "Detail", new { masterId = rowId } ). However I can't use rowId here.
You supplied ExtraParam and ExtraParamScript, but till now no idea how it works. Perhaps you have an example to shed some light on this issue. Thanks in advance!

Gerard
Coordinator
Sep 24, 2013 at 7:52 AM
Hi Gerard,

So in general those two properties are used for providing extra values that will be posted with row values to the server:
  • ExtraParam is more for server side approach, you just supply an object here while initializing the helper on it will be send back with every request
  • ExtraParamScript is a client side mechanism, it allows you to provide some JavaScript that will be evaluated on client side and the resulting object will be send back with the request
In your case you would want to go with ExtraParamScript. You will also need some "internals" knowledge (but a warning is required, as those are specifics of internal implementation they might have change at some point). The generated client side subgrid initialization code has access to one specific variable which names is rowId (and it contains exactly what you need), so you can use it in the script:
.InlineNavigator(new Lib.Web.Mvc.JQuery.JqGrid.JqGridInlineNavigatorOptions() { Edit = false, AddActionOptions = new Lib.Web.Mvc.JQuery.JqGrid.JqGridInlineNavigatorAddActionOptions()
    {
        RowId = "_empty",
        Options = new Lib.Web.Mvc.JQuery.JqGrid.JqGridInlineNavigatorActionOptions()
        {
            Url = Url.Action("InsertAnswer"),
            ExtraParamScript = "{ masterId: rowId }"
        }
    }
})
This should do the trick.

Regards,
Tomasz Pęczek
Marked as answer by TPeczek on 11/27/2013 at 2:31 AM
Sep 24, 2013 at 9:02 AM
Hi Tomasz,

Tried that, but the generated code looks like:
...
url: '/Question/AnswersSubgrid?id=' + encodeURIComponent(rowId),
datatype: 'json',
editurl: '/Question/UpdateAnswer',
jsonReader: { repeatitems: false, id: 'AnswerId' },
mtype: 'POST',
pager: '#' + subgridPagerId,
rowNum: 10,
sortname: 'Ordinal',
viewrecords: true,
height: '100%'
}).jqGrid('navGrid', '#' + subgridPagerId,
{ add: false, edit: false, del: false }).jqGrid('inlineNav', '#' + subgridPagerId,
{ edit: false, addParams: { rowID: '0', addRowParams: { url: '/Answer/InsertAnswer', extrapa});

},
viewrecords: true,
height: '100%'
}).jqGrid('navGrid', '#questionsPager',
...

There is a "extrapa", but it seems it is neither declared nor set. Any ideas?
The code looks like:
AddActionOptions = new Lib.Web.Mvc.JQuery.JqGrid.JqGridInlineNavigatorAddActionOptions()
              {
                  RowId = "0",
                  Options = new Lib.Web.Mvc.JQuery.JqGrid.JqGridInlineNavigatorActionOptions()
                  {

                      Url = Url.Action("InsertAnswer", "Answer"),
                      ExtraParamScript = "{ QuestionId: rowId }"
                  }
              }
Coordinator
Sep 24, 2013 at 10:17 AM
Hi Gerard,

The only idea I have is that it looks like a bug ;). I will investigate later today and let you know.

Regards,
Tomasz Pęczek
Coordinator
Sep 24, 2013 at 8:49 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.
Coordinator
Sep 24, 2013 at 9:26 PM
Hi Gerard,

A bug fix release (v6.3.2) is available.

Regards,
Tomasz Pęczek
Sep 25, 2013 at 7:28 AM
Thanks a lot. Bug is fixed!!