cyberhobo / ColumnFilterWidgets

This is an add-on for the DataTables plugin for jQuery that creates filtering widgets based on the data in table columns.
69 stars 34 forks source link

skipped columns get rendered anyway #13

Closed honzaves closed 11 years ago

honzaves commented 12 years ago

First of all, thanks for this amazing plugin. I hope backend data loading will work one day.

The issue I found is that div's with class 'column-filter-widget' get rendered as an empty div when the div is in the aiExclude list. This can kind of ruin layout in some browsers.

These are the lines responsible:

// Add a widget for each visible and filtered column
        $.each( oDataTableSettings.aoColumns, function ( i, oColumn ) {
            var $columnTh = $( oColumn.nTh );
            var $WidgetElem = $( '<div class="column-filter-widget"></div>' );
            if ( oColumn.bVisible && sExcludeList.indexOf( '|' + i + '|' ) < 0 ) {
                me.aoWidgets.push( new ColumnFilterWidget( $WidgetElem, oDataTableSettings, i, me ) );
            }
            me.$MenuContainer.append( $WidgetElem );
        } );

This was my solution

// Add a widget for each visible and filtered column
        $.each( oDataTableSettings.aoColumns, function ( i, oColumn ) {
            var $columnTh = $( oColumn.nTh );
            if ( sExcludeList.indexOf( '|' + i + '|' ) < 0 ) {
                var $WidgetElem = $( '<div class="column-filter-widget"></div>' );
                me.aoWidgets.push( new ColumnFilterWidget( $WidgetElem, oDataTableSettings, i, me ) );
                me.$MenuContainer.append( $WidgetElem );
            }
        } );

I also assume the "columnTh" variable can go. As far as I can see, it is not used anywhere.