JqGrid PHP: highlight results, when filtering via

2020-05-03 11:28发布

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

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

grid.php code snippet

$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);

I get this error:

Notice: Undefined variable: this

Are you able to get what I am doing wrong?

1条回答
我只想做你的唯一
2楼-- · 2020-05-03 11:37

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.

查看更多
登录 后发表回答