How to exclude rows from beeing filtered?

How to exclude rows from beeing filtered?

SlashSlash Posts: 1Questions: 0Answers: 0
edited May 2011 in General
Hi everybody

My Table looks as follows:

| subtitle 1 |
| col1 | col2 | col3 |
| subtitle 2 |
| col1 | col2 | col3 |
| col1 | col2 | col3 |

I'm using DataTable v. 1.7.6 and I need to create a filter, which allows me to exclude some specific rows from beeing filtered. In my particular case, I want to exclude my subtitle rows from beeing filtered. I could use the custom filter to achieve this, but the problem would be that the global filter is still active and would filter those rows anyway. As proposed in the documentation (http://www.datatables.net/development/filtering#global_filters), if I want to replace the global filter with my own one, I have to drop the 'f' (filtering) option from sDom. But when I do so, the integrated search-input field would not appear anymore and I would have to create my own text field, which is not what I want, since then I have to care about how to append the text nicely on top of the table and add event mechanism etc..

Is there an easy way how to achieve this?
It would be nice if prior to the filtering an exclude function is called, which directly excludes some rows of beeing filtered. It could look simillar to the custom filter function below.

[code]
$('#myTable').dataTableExt.afnExcludeFiltering.push(
function( oSettings, aData, iDataIndex ) {
return aData[0].indexOf("subtitle") >= 0; // true to exclude from filtering
}
);
[/code]

Thanks
Slash

Replies

  • jamestrendajamestrenda Posts: 1Questions: 0Answers: 0
    I, too, wish to know how to exclude certain rows from being filtered. I have a table where the first column of each row contains a checkbox. When a user searches the table, I wish for those rows that have their checkbox checked to remain visible. The reason I need this functionality is because when a user submits the form with the table in a filtered state, only the visible rows get processed. In many cases, this is not ideal for users.
  • allanallan Posts: 63,534Questions: 1Answers: 10,475 Site admin
    Currently there is no way to exclude a row from the global filter - you could define your own filtering plug-in and have it not use the global filter at all - that would work, but it might be a bit clunky.

    Added to the future feature list!

    Allan
  • zoltanseerzoltanseer Posts: 1Questions: 0Answers: 0
    Any updated in this topic? I have the same problem as Slash, only that I have a single row that I would like to exclude.

    Zoltan
This discussion has been closed.