jQWidgets Forums

jQuery UI Widgets Forums Grid Nested Grid – Accessing parent grid row data

This topic contains 1 reply, has 2 voices, and was last updated by  Dimitar 11 years, 3 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author

  • assaf.frank123
    Participant

    Hi,

    I am following the example in nestedgrids.htm .
    I would like to be able to access the outer grid row (the data) from the inner grid –
    for example, I implemented an “Add” button in the inner grid toolbar. Upon pressing add I wish to access
    the current outer row in “outerGrid”.

    How would I do this and how can I give an ID to each inner grid so I can access the grid directly later on in the code?

    Thanks.

    var nestedGridAdapter = new $.jqx.dataAdapter(adgroupssource);
    if (grid != null) {
    grid.jqxGrid({
    source: nestedGridAdapter,
    width:’90%’,
    height: 170,
    rtl:true,
    editable:true,
    selectionmode: ‘singlerow’,
    enabletooltips: true,
    showfilterrow: false,
    filterable: false,
    showtoolbar: true,
    rendertoolbar: function (statusbar) {

    // appends buttons to the status bar.
    var container = $(“<div style=’overflow: hidden; position: relative; margin: 5px;’></div>”);
    var addButton = $(“<div style=’float: right; margin-right: 5px;’><span style=’margin-right: 4px; position: relative; top: -3px;’>ADD</span></div>”);
    container.append(addButton);
    statusbar.append(container);
    addButton.jqxButton({width: 60, height: 20 });

    // add new row.
    addButton.click(function (event) {
    // Not working – there is no selectedtrowindex
    var selectedrowindex = $(“#outergrid”).jqxGrid(‘getselectedrowindex’);
    var data = $(‘#outergrid’).jqxGrid(‘getrowdata’, selectedrowindex);

    }


    Dimitar
    Participant

    Hello assaf.frank123,

    The data of the master-row of the nested grid is already provided in the initrowdetails function arguments:

    var initrowdetails = function (index, parentElement, gridElement, record) {

    index has the master-row index and record has its cells data.

    You can access these arguments directly from your addButton click callback.

    Best Regards,
    Dimitar

    jQWidgets team
    http://www.jqwidgets.com/

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.