gpt4 book ai didi

javascript - jqgrid getCell 奇怪的行为

转载 作者:行者123 更新时间:2023-11-29 22:19:17 25 4
gpt4 key购买 nike

我有一个 jqgrid 和一个 getCell 方法,它根据 id 返回单元格的值。它仅适用于网格的第一行,在其他情况下 identifyImg = false:

var ids = jQuery("#myGrid").getDataIDs(); 
for(var i=0;i<ids.length;i++){
var identifyImg = $('#myGrid').jqGrid('getCell', i, 'idState');
alert(identifyImg); // return false after first row
if(identifyImg == '1'){
//DO SOMETHING
}
}

列定义如下:

{name:'idState',index:'idState', width:55}

并且正确填充了数字。我该如何解决这个问题?

最佳答案

你应该使用

 $('#myGrid').jqGrid('getCell', ids[i], 'idState');

代替

 $('#myGrid').jqGrid('getCell', i, 'idState');

我还想提一下,在大多数情况下,不需要对从 getDataIDs 返回的 ID 使用循环。在 旧版本的 jqGrid 中,在 loadCompletegridComplete 中自定义 jqGrid 是一种很好的方法。现在有更多更好的选择(从性能的 Angular 来看)。例如,如果您需要根据一列的内容更改一个单元格的某些样式或其他属性,您可以使用 cellattr(请参阅 the answerthe answerthe answerthe answer或其他)。如果您需要根据一列的内容更改整行的某些属性,您可以使用 rowattr(参见 the answer)。在其他情况下,如果您需要根据另一个单元格的内容更改单元格的内容(不是属性),您可以使用 custom formatter .

关于javascript - jqgrid getCell 奇怪的行为,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13320742/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com