0
votes

Basically it is almost the same example as given http://mleibman.github.io/SlickGrid/examples/example-header-row.html Only changes I made:

Fist is that filter is applied only a few columns by

    if(args.column.id == 'name' || args.column.id == 'contract'){
        var s = $("<input type='text'>");
        s.data('columndata', args.column.id)
        .val(columnFilters[args.column.id])
        .appendTo(args.node);
    };

Second difference is data is not inserted into DataView in construction. I have ajax call which loads data in json format and then use dataView.setItems to inject data array into DataView.

Third changes I made, my filter checks if value in row, column, not exact match.

function filter(item){
for(var columnId in columnFilters){
    if(columnId != undefined && columnFilters[columnId] != ''){
    var c = obj.grid.getColumns()[obj.grid.getColumnIndex(columnId)];
    var value1 = item[c.field].toUpperCase();
    var value2 = columnFilters[columnId].toUpperCase();
    if(value1.indexOf(value2)==-1){
        return false;
    };
    };
};
return true;
};

Generally filter is working. It is even filtering correctly. If there is 2 items(rows) contains say 'herb' that filter will find 2 rows.

But since it found 2 rows it will show 2 first rows.

It works this way. If filter found N correct values it will show first N rows.

I did try to debug dataview, but it operates only with rows amount not a rows number matching param

1

1 Answers

0
votes

location of problem was found. i did incorrectly override method getItem() which returned wrong items couse i passed row number into it