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: 21,300Questions: 26Answers: 4,945

    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,365Questions: 39Answers: 395
    edited December 2017

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

  • allanallan Posts: 63,455Questions: 1Answers: 10,465 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: 63,455Questions: 1Answers: 10,465 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: 63,455Questions: 1Answers: 10,465 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: 63,455Questions: 1Answers: 10,465 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: 63,455Questions: 1Answers: 10,465 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.