How to filter selected rows for multiselect grid

As the subject says, I need to filter a grid based on user selected rows.

The following code does not work, but I don’t understand why.

    function filter_grid()
    {
        var ids = mygrid.getSelectedRowId();
        if(ids)
        {
            var selectedRows = ids.toString().split(',');
            for(i=0; i<selectedRows.length;i++)
            {
                mygrid.filterBy(0, mygrid.cellById(selectedRows[i], 0).getValue(), (i==0?false:true));
            }
        }
        else
        {
            mygrid.filterBy(0,"");
        }
    }

So, filterBy() is called with preserve=false for the first row, then true for subsequent rows, which the documentation suggests will allow me to filter by multiple values.

This ends up with no rows filtered (although it works for the very first selected row). If I reverse the value of preserve, the filter will only include the last selected row.

Seems like I’m missing something pretty basic here.

Thanks, Steve

Your code is correct and work as expected.
When grid is filtered by first selected row, grid contains only one row.
Then you filter grid by by first value of second selected row.
But current grid state doesn’t contain row with such value, so grid is empty.

You can use 2nd parameter of filterBy() method as function to filter grid by selected rows value with one iteration. Please find more information here docs.dhtmlx.com/doku.php?id=dhtm … t_filterby