javascript - JQGrid自定义汇总匹配

标签 javascript jquery jqgrid summary

已成功将 JQGrid 用于几个项目,但在这个示例中努力让它执行我想要的操作。

我想我需要创建一个自定义 summaryType 来检查记录是否匹配,而不是 sum、avg、min、max 等。

enter image description here

我需要检查是否记录了“Us”,匹配了“Them”,并在红色 X 所在的位置显示了文本“Match”,谁能给我一些关于如何执行此操作的指示。

最佳答案

多亏了对此 answer 的评论,当您了解它的工作原理时,它会出奇地简单

the jqGrid will call your function for every row (this is why you pass it to the option only by name, jqGrid requires the actual function not its result) - for first row the val should be empty and for next rows it should be the result of previous call.

在你的colModel中设置一个summaryType作为你的函数名,然后使用这些函数

function numberMatch(val, name, record) {
    if (val || 0 - record[name] == 0) {
        return "Match";
    } else {
        return "unmatched";
    }    
}

function textMatch(val, name, record) {
    if (val || '' === record[name]) {
        return "Match";
    } else {
        return "unmatched";
    }    
}

关于javascript - JQGrid自定义汇总匹配,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31431437/

相关文章:

javascript - 如何即时更新一个平滑更新的进度条?

javascript - 当用户在文本框中键入内容时,过滤由 java 代码添加的 HTML 选择元素

jquery - 结合jQuery UI的盲动和滑动动画方法

jquery - 如果免费的 jqgrid 表单编辑,如何增加字体大小和元素高度

jquery - jQGrid设置列宽

php - Jqgrid - 鼠标单击不选择行

javascript - 将 JqGrid 列模式显示为日期和超链接显示 NAN/NAN/NAN

javascript - 为什么现在字符串模板比字符串连接更受欢迎?

javascript - JavaScript 过滤器的替代返回 - 如果未找到客户端则显示消息

javascript - 执行 window.print 时的边距和填充问题