Invalidate rows when global filter is used?

Invalidate rows when global filter is used?

guillochonguillochon Posts: 56Questions: 19Answers: 0

I'd like to invalidate rows when the global filter is used, however I don't know how to access the invalidate function from within a search function.

Here's what I currently have, comment is where I'd like to invalidate:

        jQuery.fn.dataTable.ext.search.push(
            function( oSettings, aData, iDataIndex ) {
                for ( var i = 0; i < aData.length; i++ )
                {
                    if ( floatColInds.indexOf(i) !== -1 ) {
                        if ( !advancedFloatFilter( aData[i], floatColValDict[i] ) ) return false;
                    }
                }
                // INVALIDATE ROW HERE, BUT WHAT FUNCTION?
                return true;
            }
        );

Answers

  • guillochonguillochon Posts: 56Questions: 19Answers: 0

    Hmmm, I think all I want to do is invalidate the "current" rows, but the function being pushed to search runs on every row one by one. So what I need to do is push a function to search that only runs once, after the filtering has completed.

  • allanallan Posts: 61,934Questions: 1Answers: 10,155 Site admin

    You could potentially use new $.fn.dataTable.Api( oSettings ).row( iDataIndex ).invalidate(), but that sounds horribly expensive to me. What's the use case?

    I would have said you would be much better invalidating the data after the data has been updated.

    Allan

  • allanallan Posts: 61,934Questions: 1Answers: 10,155 Site admin

    You could potentially use new $.fn.dataTable.Api( oSettings ).row( iDataIndex ).invalidate(), but that sounds horribly expensive to me. What's the use case?

    I would have said you would be much better invalidating the data after the data has been updated.

    Allan

  • guillochonguillochon Posts: 56Questions: 19Answers: 0

    OK, figured it out! You need to attach to the search event:

            table.on( 'search.dt', function () {
                table.rows({page:'current'}).invalidate();
            } );
    

    This will invalidate all rows on the current page before the redraw, exactly what I was looking for.

This discussion has been closed.