How to get a cell value in JQGrid?

2019-03-18 08:27发布

How to get a cell value in JQGrid?

If I use the following syntax –

var ret = jQuery("#MyGrid").jqGrid('getRowData', id);
ret = ret.ProductId;

it returns the following HTML.

'input class="editable" name=" ProductId " id="0_ ProductId " style="width: 98%;" type="text"'

I actually need the value of the cell.

Thanks. Dev

2条回答
再贱就再见
2楼-- · 2019-03-18 09:21

If you try to get the value of a row while it is being edited, you will retrieve markup (as in your example), instead of the actual value. To quote the jqGrid Documentation for getRowData:

Do not use this method when you editing the row or cell. This will return the cell content and not the actual value of the input element

The best way around this is to save your row data before calling getRowData, although alternatively if that is not an option you will have to parse the markup yourself. Which actually is not that hard to do in jQuery, but is still a pain.

查看更多
对你真心纯属浪费
3楼-- · 2019-03-18 09:28

If you only need the value of a cell that has already been saved, you can get it with this

$('#myTable').jqGrid('getCell',row_id,'column_name');
查看更多
登录 后发表回答