Mistake in page.jumpToData ?

Mistake in page.jumpToData ?

vogomatixvogomatix Posts: 38Questions: 3Answers: 7
edited May 2014 in Bug reports

The page.jumpToData interface claims to be function(data, column) yet the example given lower down is: table.page.jumpToData( 0, "Allan Jardine" );

i.e. column, data

Actually the latter is more intuitive.....

Also jumpToData with a means of uniquely identifying a row through multiple columns might be useful....e..g table.page.jumpToData( ["Allan", "Jardine"], [0. 1] );

page.jumpToData with multiple data columns

    $.fn.dataTable.Api.register( 'page.jumpToData()', function ( data, column ) {
    
        var dt, pos, i;
        
        if ($.isArray(data)) {
            // data and columns are arrays
            dt = this.columns( column).data();
            for (pos = dt[0].indexOf( data[0]); pos >= 0; pos = dt[0].indexOf( data[0], pos+1)) {
                // check match on remaining values
                for (i = 1; i < dt.length  &&  (dt[i][pos] == data[i]); i++) {
                }
                if (i === dt.length) break; // found a match
            }
        } else {
            dt = this.column(column).data(); // array of column data
            pos = dt.indexOf( data ); // find index in column array matching data
        }

        if ( pos >= 0 ) {
            var page = Math.floor( pos / this.page.info().length );
            this.page( page ).draw( false );
        }
     
        return this;
    } );
This discussion has been closed.