SearchPane - column selection

SearchPane - column selection

FreedyFreedy Posts: 26Questions: 4Answers: 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: 2,817Questions: 19Answers: 624

    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: 2,084Questions: 14Answers: 230
    edited December 2017

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

  • allanallan Posts: 46,589Questions: 1Answers: 6,505 Site admin

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

    Allan

  • FreedyFreedy Posts: 26Questions: 4Answers: 0

    Hi,
    Would the syntax be something like this?

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

    Thanks,
    Thomas

  • allanallan Posts: 46,589Questions: 1Answers: 6,505 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: 26Questions: 4Answers: 0

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

    Thanks,
    Thomas

  • allanallan Posts: 46,589Questions: 1Answers: 6,505 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: 12Questions: 3Answers: 0

    this column selection didn't for me

            $('#example').DataTable({
                searchPane: {
                    columns: ['Position:name', 'Office:name', 'Age:name']
                    , threshold: 0
                }
            });
    
  • allanallan Posts: 46,589Questions: 1Answers: 6,505 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: 12Questions: 3Answers: 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: 46,589Questions: 1Answers: 6,505 Site admin
    $('#example').DataTable({
        searchPane: {
            columns: [':contains("Position")', ...]
            , threshold: 0
        }
    });
    

    should do it.

    Allan

  • DalemanDaleman Posts: 12Questions: 3Answers: 0

    @allan,
    It works perfectly.

    Thank you

Sign In or Register to comment.