How to get a jqGrid selected row cells value

后端 未结 6 657
忘掉有多难
忘掉有多难 2020-12-08 13:40

Does anyone know how to get the cells value of the selected row of JQGrid ? i m using mvc with JQGrid, i want to access the value of the hidden column of the selected row ?<

6条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-08 14:30

    Use "selrow" to get the selected row Id

    var myGrid = $('#myGridId');

    var selectedRowId = myGrid.jqGrid("getGridParam", 'selrow');

    and then use getRowData to get the selected row at index selectedRowId.

    var selectedRowData = myGrid.getRowData(selectedRowId);

    If the multiselect is set to true on jqGrid, then use "selarrrow" to get list of selected rows:

    var selectedRowIds = myGrid.jqGrid("getGridParam", 'selarrrow');

    Use loop to iterate the list of selected rows:

    var selectedRowData;

    for(selectedRowIndex = 0; selectedRowIndex < selectedRowIds .length; selectedRowIds ++) {

       selectedRowData = myGrid.getRowData(selectedRowIds[selectedRowIndex]);
    

    }

提交回复
热议问题