jQuery 如何在jqgrid中更改行的特定单元格值

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12674663/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 11:55:13  来源:igfitidea点击:

How to change a row's particular cell value in jqgrid

jqueryjqgridjqgrid-asp.net

提问by Yasser Shaikh

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.

我想更改特定行的单元格值,我有行 ID。我尝试使用以下方法。但它不起作用。

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

I am using loadonce: true

我在用 loadonce: true

Please can someone help me with this. Thanks

请有人帮我解决这个问题。谢谢

回答by tpeczek

You can use getRowDataand setRowDatamethods to achieve this (they are working directly with data array):

您可以使用getRowDatasetRowData方法来实现这一点(它们直接使用数据数组):

var rowData = $('#my-jqgrid-table').jqGrid('getRowData', rowId);
rowData.Currency = '12321';
$('#my-jqgrid-table').jqGrid('setRowData', rowId, rowData);

回答by Justin Levene

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.

检查所有变量是否正确,因为您所做的似乎是正确的。loadOnce 没有影响,你肯定是其他地方出错了。

  • Are you sure the row name is Currency (not the index)
  • Check the variable rowId, should it be rowid or rowID
  • 你确定行名是货币(不是索引)
  • 检查变量 rowId,它应该是 rowid 还是 rowID

回答by Yasser Shaikh

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

感谢大家的努力,在一位工作朋友的帮助下,我设法使用一些 jquery 完成了这项工作。

Here is what I did...

这是我所做的...

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

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

使用这里3是因为我想更改我的第 3 列。

Hope this is useful for someone in future :)

希望这对将来的某人有用:)