JQuery and JqGrid retrieve data from row

后端 未结 2 1427
梦毁少年i
梦毁少年i 2020-12-14 19:27

How I can retrieve data from jqgrid row, if I have only the number of the row?

For example, what do I have to do if I want the id column of the 3rd row?

相关标签:
2条回答
  • 2020-12-14 20:08

    Please, be carefull with methods getCell and getRowData if case you are editing the row or cell. "This will return the cell content and not the actuall value of the input element."

    0 讨论(0)
  • 2020-12-14 20:11

    You can get the data by row id. So you can do following:

    var index = 2; // zero-based index of row so it means the 3rd row
    var rowId = jQuery('#list tr:eq('+index+')').attr('id');
    

    (here I suppose that the <table> element of your jqGrid has id="list"). After you know the id of the row you can get the row data with respect of getRowData method or the data from one cell only with respect of getCell method:

    var dataFromTheRow = jQuery('#list').jqGrid ('getRowData', rowId);
    var dataFromCellByColumnIndex = jQuery('#list').jqGrid ('getCell', rowId, 7);
    var dataFromCellByColumnName = jQuery('#list').jqGrid ('getCell', rowId, 'Tax');
    
    0 讨论(0)
提交回复
热议问题