How to change a row's particular cell value in

2019-01-22 06:42发布

I want to change a particular rows's cell value, I have the row Id. and I have tried using the following. But it doesnt work.

$("#my-jqgrid-table").jqGrid('setCell',rowId,'Currency', '12321');

I am using loadonce: true

Please can someone help me with this. Thanks

3条回答
啃猪蹄的小仙女
2楼-- · 2019-01-22 07:25

Thanks all for your effort, with help of a friend at work I managed to get this working with some jquery.

Here is what I did...

$("#" + rowId).find('td').eq('3').html('newText')

here 3 is used because I want to change my 3rd column.

Hope this is useful for someone in future :)

查看更多
啃猪蹄的小仙女
3楼-- · 2019-01-22 07:37

You can use getRowData and setRowData methods to achieve this (they are working directly with data array):

var rowData = $('#my-jqgrid-table').jqGrid('getRowData', rowId);
rowData.Currency = '12321';
$('#my-jqgrid-table').jqGrid('setRowData', rowId, rowData);
查看更多
萌系小妹纸
4楼-- · 2019-01-22 07:42

Here is the correct way according to the documentation :-

$("#my-jqgrid-table").jqGrid("setCell", rowid, "Currency", "New value");

Check that all variables are correct as what you did seems correct. loadOnce has no impact, you must have a mistake elsewhere.

  • Are you sure the row name is Currency (not the index)
  • Check the variable rowId, should it be rowid or rowID
查看更多
登录 后发表回答