Jqgrid中的计算列

编程入门 行业动态 更新时间:2024-10-26 22:17:13
本文介绍了Jqgrid中的计算列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有以下网格-

jsfiddle/ht94wbtr/1/,

请参见下图

在此网格中,我希望有一个计算出的总红细胞"列,如下面的示例图像所示

in this Grid, i want to have a calculated column 'Total Red Cells' like below sample image

在Oleg先生的帮助下,我得到了下面的代码,该代码可用于Footer

with the help of Oleg sir, i got this below code which can be used for Footer

var errorInfo = {id: "Errors:", color_name: 0, character_name: 0}; var i, item; for (i = 0; i < mydata.length; i++) { item = mydata[i]; if ($.inArray(item.color_name, hilightcolorcell) < 0) { errorInfo.color_name++; } if ($.inArray(item.character_name, hilightcahractercell) < 0) { errorInfo.character_name++; } } footerrow: true, userDataOnFooter: true, userData: errorInfo //{ id: "Errors:", color_name: 2, character_name: 2 }

我想知道如何遍历color_name和character_name列,并在计算出的列"Total Red Cells"中显示总错误计数,如示例图像所示.请帮忙.

i would like to know how to loop through color_name and character_name columns and display the total error count in a calculated column 'Total Red Cells' as shown in the sample image. please help.

推荐答案

如果我正确理解了您的需求,那么解决方案将非常简单.首先,需要定义要保留/显示总红格"信息的列.让我们将该列命名为redtotal.然后,应扩展errorInfo来保存具有相应值的redtotal属性.相应的代码可能类似于errorInfo

If I correctly understand what you need then the solution would be very easy. First of all you need define the column where you will be hold/display the "Total red cells" information. Let us the column have the name redtotal. Then you should extend errorInfo to hold redtotal property with the corresponding value. The corresponding code could be like errorInfo

var errorInfo = {id: "Errors:", redtotal: 0, color_name: 0, character_name: 0}; var i, item; for (i = 0; i < mydata.length; i++) { item = mydata[i]; if ($.inArray(item.color_name, hilightcolorcell) < 0) { errorInfo.color_name++; errorInfo.redtotal++; } if ($.inArray(item.character_name, hilightcahractercell) < 0) { errorInfo.character_name++; errorInfo.redtotal++; } }

您将在 jsfiddle/OlegKi/ht94wbtr/4/上看到结果

更多推荐

Jqgrid中的计算列

本文发布于:2023-10-13 20:27:33,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1488992.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Jqgrid

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!