Data tables filtering for multiple words

Data tables filtering for multiple words

syamgannasyamganna Posts: 4Questions: 0Answers: 0
edited March 2010 in General
Hi Allan,
I am using data tables for my project for the first time. It really having cool features with very minimal coding. I am coming across some probs.
Data tables filtering is not working properly, if I am filtering on columns if I am giving 2 words a sentence in the filtering it is looking for different words matching rather than the complete sentence. will it be possible to search only for the matching sentence.
Also how to ignore the filtering for particular column, I am having a img icon where it has URL for the link, if I just type a number , if number is there in the URL , its displaying back those results also.

Thanks
Syam

Replies

  • allanallan Posts: 63,407Questions: 1Answers: 10,452 Site admin
    1. Filtering - this is DataTables typing to be smart - and is a built in feature, which currently can't be disabled. What DataTables does is break the string up on space characters and then tries to match against that. The way match a single string which is unbroken, is to us a custom filter: http://datatables.net/development/filtering (look at the "Custom global filters" section). It's not ideal - but it is possible. The next version of DataTables will provide more flexibility for this.

    2. You can set bFilter:false ( http://datatables.net/usage/columns#bFilter ) to remove a specific column from filtering.

    Allan
  • syamgannasyamganna Posts: 4Questions: 0Answers: 0
    Thanks Allan,
    for your prompt reply.

    hope will get next version soon with custom filters.

    Thanks
    Syam
  • syamgannasyamganna Posts: 4Questions: 0Answers: 0
    Hi Allan,
    for some reason disabling the searchable for a column is not working if I disable the sorting for all columns.

    my code is like this.
    jQuery(document).ready(function() {
    jQuery('#tempLib').dataTable({
    "bPaginate": false,
    "bLengthChange": false,
    "aoColumns": [
    { "bSearchable": false },
    null,
    null,
    null
    ],
    "aaSorting": [[ 1, "asc" ]],
    "aoColumns": [
    { "bSortable": false },
    { "bSortable": false },
    { "bSortable": false },
    { "bSortable": false }
    ],
    "bInfo": false,
    "bAutoWidth": false } );
    });

    My requirement is very simple I want all the data to be sorted by second column by default, and I dont want any sorting later, also I dont want first column to be searchable, as it has hyperlink and I am passing some Ids in the URL, it is searching those Ids also.
    Can you please let me know what is wrong in the above code.

    If I just remove this part
    "aoColumns": [
    { "bSortable": false },
    { "bSortable": false },
    { "bSortable": false },
    { "bSortable": false }
    ],

    It is not searching for the first column which is working fine, but I am getting sorting option for all the column names on top, which I dont need.

    Please suggest.

    Thanks
    Syam
  • TomCTomC Posts: 43Questions: 0Answers: 0
    Why are you defining aoColumns twice?
    This should work:
    "aoColumns": [
    { "bSearchable": false, "bSortable": false },
    { "bSortable": false },
    { "bSortable": false },
    { "bSortable": false }
    ]
  • syamgannasyamganna Posts: 4Questions: 0Answers: 0
    Thanks Tom,
    it worked.
    Syam
This discussion has been closed.