Filtering in dhtmlGrid

Hello,

I use the following code to filter some data in a grid:

var filter_list = ""; for ( var i = 0; i < grid.getColumnsNum() - 1; i++) { if (grid.getColType(i) == "avq_num") { filter_list = filter_list + ",#numeric_filter"; } else if (...) { ... } else { filter_list = filter_list + ",#text_filter"; } } grid.attachHeader(filter_list.substr(1));

and I test the case when I have text_filter.
So let’s say that we have a column with currencies and I start typing in the filter and I write “e”.
Then this works fine and it filters the rows and keeps only the euros.
If I continue typing and I write something like “ez” then normally everything should disappear from the screen because there is no currency starting with “ez”.
However, what actually happens is that it keeps the previous results that I had with the “e”. So this is not the desired behaviour.

I hope that the description of the problem is clear :slight_smile:

Any idea? Or anyone else who had the same problem?

Thanks a lot in advance!

By default, filters will check that types string exists anywhere in the related column’s value. That means, when typing “ez” it will show all next “ezaa”, “aeza”, “aaez”. It possible to change logic and force strict filtering ( only rows which starts from “ez” )

In any case, filter must not show a string that doesn’t contain the “ez”. If you have such situation - please share a demo link or any kind of a sample.

Thank you for your answer :slight_smile:
I’m not talking about substring filtering. This works fine.
The problem is that when you start typing then this starts filtering according to what you typed but when you reach/create a string that doesn’t exist in the data, then it continues to show the last filtering instead of an empty set.

You can see a sample of this behaviour in the attached screenshots.

I also have tested this in more complex cases with substring or combined filters of many columns and it acts exactly the same. I just show this simple case here.

Thanks again :slight_smile:






Default behavior is to hide all rows when there is no match for the filter criteria.

dhtmlx.com/docs/products/dhtmlxT … ering.html

Please share a demo link or any kind of a sample.

Yes you are right :slight_smile: The default behaviour is fine! It was just a bug in one of the overridden functions… Now this is solved.

But now there is another question about the filtering. I need to modify the filtering in the following way:
If we have an empty cell in the tree-grid and the row of this cell has children (not-bottom level row), then we want this cell (and the corresponding row) to be treated as it contains the text we wrote in the filter area of this column (regardless of the text we wrote in the filter).

For example, let’s take the following data set (we show only the top level rows).
If we filter the value date by “s” then everything works fine.
Now, if we also filter the ref. curr. by “e” then we get an empty screen because this cell is empty.

Of course this is the default behaviour. But in this case the top level never contains information about the reference currency. So I don’t want everything to be disappeared just because we have empty cells.

So, as far as I understand, I need to customize the filterByAll function, but I cannot find what exactly I need to modify there.

Any tip/help about this?
Thanks a lot in advance :slight_smile:






Check setFiltrationLevel api, especially the second parameter docs.dhtmlx.com/treegrid__filter … elshowmode

It allows to configure filtering in treegrid, that it will run for child items while preserving top items always visible.

Thanks for your answer, but this doesn’t work for me… unfortunately.
I want to show a row only when it has an empty cell in the column that I filter, not always.

So, I summarize what I need:

1. Filter all the levels 2. For the bottom-level rows: If the cell contains the filter-text, then show this row. Else, don't show this row. 3. For all the other levels (non-bottom-levels): If the cell is empty, then show this row. Else: if the cell contains the filter-text, then show this row. else, don't show this row. 4. When you show a row, show also all the hierarchy path up to this row.

Any other idea?

It can be done only through customization of filterTreeBy method, or you can define a custom filtering function that will take all above in account, it will mark the row as match if it contains the text in question OR when it an empty cell and this is not a bottom level