Complex table filtering

Complex table filtering

RRStoyanovRRStoyanov Posts: 12Questions: 0Answers: 0
edited October 2009 in General
Hello,

I have my table up and running with input filters, but I want to add also select filter and range filter. I have those 2 questions:
1) can I rename my filters so every filter to send it's own name to my server side script instead of sSearch_? (for example my first column filter to be called sSearch_UID, my second column to be called sSearch_Username and my range filter to be send as sSearch_Trades_min and sSearch_Trades_max)

2) How to combine those 3 filter types so my table to get sorted correct? Currently when I add a select filter, it sends only its value and it's send as sSearch_0, but my server side knows other column name connected to sSearch_0. If it's possible to send the id of the filter, so for example my select should be sSearch_5 (if we assume that my first question is not possible), that I would like to know this too.

I spend an hour or so to search in the forum, but didn't find something which can help me. Sorry ;(

Thanks in advance!

Replies

  • RRStoyanovRRStoyanov Posts: 12Questions: 0Answers: 0
    edited October 2009
    OK allan,

    before you answering to my first question, let me tell you what I did about it :)

    in jquery.dataTables.js
    [code]
    /*
    * Variable: sSearchIDs
    * Purpose: Naming sSearch_ with custom suffix
    * Scope: jQuery.dataTable.classSettings
    */
    this.sSearchIDs = [];
    [/code]
    [code]
    /* Filtering */
    if ( oSettings.oFeatures.bFilter !== false )
    {
    aoData.push( { "name": "sSearch", "value": oSettings.oPreviousSearch.sSearch } );
    aoData.push( { "name": "bEscapeRegex", "value": oSettings.oPreviousSearch.bEscapeRegex } );
    for ( i=0 ; i
  • RRStoyanovRRStoyanov Posts: 12Questions: 0Answers: 0
    And... I manage to find myself how to do deal with it. Will be happy to see how other ppl make their complex filtering.
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Hi RRStoyanov,

    Nice one - good to hear you managed to get it sorted yourself and thanks for pasting in your solution as well.

    Regards,
    Allan
  • MadLordMadLord Posts: 10Questions: 0Answers: 0
    Here still mine 5 cents )))...
    1) sSearchName - this parameter replaces standard variable 'sSearch_'
    initialize:
    [code]
    "aoColumns":
    [
    /* th */ { "sSearchName": "cname"}
    ]
    [/code]
    in DataTables:
    [code]_fnMap( oCol, oOptions, "sSearchName" );[/code]
    and
    [code]
    /* Filtering */
    if ( oSettings.oFeatures.bFilter !== false )
    {
    aoData.push( { "name": "sSearch", "value": oSettings.oPreviousSearch.sSearch } );
    aoData.push( { "name": "bRegex", "value": oSettings.oPreviousSearch.bRegex } );
    for ( i=0 ; i
  • MadLordMadLord Posts: 10Questions: 0Answers: 0
    about this
    [code]else if (oSettings.aoColumns[i].bSearchable !== false)[/code]
    I think it is not necessary to add variables if they aren't need...
This discussion has been closed.