JqG​​rid PHP:通过工具栏过滤时突出显示结果 [英] JqGrid PHP: highlight results, when filtering via toolbar

查看:77
本文介绍了JqG​​rid PHP:通过工具栏过滤时突出显示结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用过滤器工具栏时,我想突出显示搜索结果.

I would like to highlight the search results, when using the filter toolbar.

我尝试使用解决方案 Oleg 此处提供了, 但它在PHP的JqSuite中不起作用.

I tried to use the solution Oleg and Abhishek Simon provided here, but it is not working in JqSuite for PHP.

grid.php 代码段

$highlighting = <<<HIGHLIGHTING

function () {
    var filters, i, l, rules, rule, iCol, $this = $(this);
    if (this.p.search === true) {
        filters = $.parseJSON(this.p.postData.filters);
        if (filters !== null && typeof filters.rules !== 'undefined' &&
                filters.rules.length > 0) {
            rules = filters.rules;
            l = rules.length;
            for (i = 0; i < l; i++) {
                rule = rules[i];
                iCol = getColumnIndexByName($this, rule.field);
                if (iCol >=0) {
                    $('>tbody>tr.jqgrow>td:nth-child(' + (iCol + 1) +
                        ')', this).highlight(rule.data);
                }
            }
        }
    }
}

HIGHLIGHTING;

$grid->setGridEvent('loadComplete',$highlighting);

我收到此错误:

注意:未定义的变量:

你能弄错我在做什么吗?

Are you able to get what I am doing wrong?

推荐答案

我自己不使用PHP.无论如何,您应该知道您在页面上使用的网格的ID.例如,如果是id="grid",则可以在函数代码内用$("#grid")[0]替换this.

I don't use PHP myself. Anyway you should know the ID of the grid which you use on the page. If it is for example id="grid" then you can replace this with $("#grid")[0] inside of the code of the function.

这篇关于JqG​​rid PHP:通过工具栏过滤时突出显示结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆