SearchPane - column selection

SearchPane - column selection

FreedyFreedy Posts: 33Questions: 5Answers: 0

Hi,

I have a quick question, when using the SearchPane how would I use just the 2nd and 3rd columns for
filtering?

Thanks,
Thomas

This question has accepted answers - jump to:

Answers

  • kthorngrenkthorngren Posts: 20,143Questions: 26Answers: 4,736

    Depending on what you want you can start with one of these two examples:

    https://datatables.net/examples/api/multi_filter.html

    https://datatables.net/examples/api/regex.html

    Kevin

  • tangerinetangerine Posts: 3,342Questions: 35Answers: 394
    edited December 2017

    It's explained in the SearchPane documentation. Use the "columns" option: " The columns that should have search panes shown."

  • allanallan Posts: 61,446Questions: 1Answers: 10,054 Site admin

    Yup - options are documented in the blog post include the columns option @tangerine mentioned.

    Allan

  • FreedyFreedy Posts: 33Questions: 5Answers: 0

    Hi,
    Would the syntax be something like this?

    searchPane: {
        columns: [
                {'name' : 'JobID'},
                {'name' : 'Customer'}
            ],
    
        threshold: 0
    },
    

    Thanks,
    Thomas

  • allanallan Posts: 61,446Questions: 1Answers: 10,054 Site admin
    Answer ✓

    No it would be:

    searchPane: {
      columns: [ 'JobID:name', 'Customer:name' ],
      threshold: 0
    }
    

    This assumes you've set the column names using columns.name.

    See the column-selector documentation for details of what you can use as column selectors.

    Allan

  • FreedyFreedy Posts: 33Questions: 5Answers: 0

    Thank you,
    I was missing the columns.name Option. Will there be support for serverSide
    in the future?

    Thanks,
    Thomas

  • allanallan Posts: 61,446Questions: 1Answers: 10,054 Site admin
    Answer ✓

    Possibly. At the moment the data to show is determined by the data in the table. With server-side processing, the server would need to pass a list of options to the client-side. That is certainly something that can be looked into.

    I've added it to the list here.

    Allan

  • DalemanDaleman Posts: 17Questions: 5Answers: 0

    this column selection didn't for me

            $('#example').DataTable({
                searchPane: {
                    columns: ['Position:name', 'Office:name', 'Age:name']
                    , threshold: 0
                }
            });
    
  • allanallan Posts: 61,446Questions: 1Answers: 10,054 Site admin

    You don't have any columns that match those selectors though. The :name selector specifically matches against the columns.name option, not the text in the header cell.

    You'd need to use the jQuery :contains select - e.g. :contains('Position').

    Allan

  • DalemanDaleman Posts: 17Questions: 5Answers: 0

    @allan,
    Thanks for your reply. But I'm still stuck understanding your statemen:
    use the jQuery :contains select - e.g. :contains('Position')

    can you give me in live demo

    Thank in Adv

  • allanallan Posts: 61,446Questions: 1Answers: 10,054 Site admin
    $('#example').DataTable({
        searchPane: {
            columns: [':contains("Position")', ...]
            , threshold: 0
        }
    });
    

    should do it.

    Allan

  • DalemanDaleman Posts: 17Questions: 5Answers: 0

    @allan,
    It works perfectly.

    Thank you

This discussion has been closed.