checkbox to select all options in searchPanes

checkbox to select all options in searchPanes

Khalid TeliKhalid Teli Posts: 251Questions: 71Answers: 0

Hi,
I was just finding a ways to see if we can use check boxes inside searchpanes to filter data, and I came across this example by @colin live.datatables.net/jayilaqa/1/edit , I was wondering if we can have a checkbox at top of each pane to select all option?

I know by default everything is selected, just to make it easy for the users I want to have the selectAll checkbox.

Thank you

Answers

  • sandysandy Posts: 913Questions: 0Answers: 236

    Hi @Khalid Teli ,

    That's not something that is supported as standard within SearchPanes. Your best bet would be to create a button, and then have the action call the rows().select() api method on each SearchPane DataTable.

    I've edited colins example to show this working.

    Thanks,
    Sandy

  • Khalid TeliKhalid Teli Posts: 251Questions: 71Answers: 0

    Hello @sandy
    Thank you. That will do it.
    However, if we need to select values from just one pane for example let us say select all rows from position.
    Can we do something like this, which will select only rows from that particular pane:

    $('#selectSP').on('click', function() {
        $('.dtsp-searchPane.dtsp-columns-2 table.dataTable').DataTable().rows().select().draw();     
      })
    

    Thanks

  • sandysandy Posts: 913Questions: 0Answers: 236

    Hi @Khalid Teli ,

    Not quite - that class is to indicate the layout of the panes rather than their index. You would be better to do something like in this example.

    $('#selectSP').on('click', function() {
        $('.dtsp-searchPane table.dataTable:eq(1)').DataTable().rows().select().draw();
      })
    

    Thanks,
    Sandy

  • seliantoselianto Posts: 1Questions: 0Answers: 0
    edited April 10

    Sandy, that works very well, but only for column 1 (Position).
    If I change your code to

    $('.dtsp-searchPane table.dataTable:eq(2)').DataTable().rows().select().draw();
          })
    

    (literally only changing eq(1) to eq(2)), I would expect it to select all options for the next column (Office), but nothing happens.
    How do I get it to work?

    Simone

Sign In or Register to comment.