jQuery UI Widgets Forums Grid get Row Data on button click with jqgrid having dynamic id

This topic contains 2 replies, has 2 voices, and was last updated by  Dimitar 9 years ago.

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

  • sriharshag7
    Participant

    Hi,
    App has a page with multiple jqxgrids. Id of each grid is dynamically generated.
    There is a button in each row of grids. On click of button, i need to figure out row data. If we have id of the grid, it is straight forward.
    But how do we get the row data if we don’t know the corresponding grid id?

    columns: [

    { text: ”, dataField: ‘button’, width: ‘8%’, columntype:’button’, cellsrenderer: function () {
    return ‘Enter’;
    }, buttonclick: function (row, event) {
    // id = $(“unknown”).jqxGrid(‘getrowid’, row);

    }
    }


    sriharshag7
    Participant

    Followed below way to get row data. Not sure if this is the optimal way to achieve it.
    All grids were starting with similar id.

    { text: '', dataField: 'button', width: '8%', columntype:'button', cellsrenderer: function () {
    		                     return 'Enter';
    		                 }, buttonclick: function (row, event) {
    
    		                     var button = $(event.currentTarget);
    		                     var grid = button.parents("[id^=jqxGrid]");
    		                     
    		                     var rowData = grid.jqxGrid('getrowdata', row);
    		                     
    
    		                 }
    		              }

    Dimitar
    Participant

    Hello sriharshag7,

    Here is an alternative solution:

    buttonclick: function(row, event) {
    
        var button = $(event.currentTarget);
        var grid = $('#' + this.owner.element.id);
    
        var rowData = grid.jqxGrid('getrowdata', row);
    
    }

    Best Regards,
    Dimitar

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

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

You must be logged in to reply to this topic.