Pregunta

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?

¿Fue útil?

Solución

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.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top