DataTables select all question

DataTables select all question

pain19pain19 Posts: 57Questions: 5Answers: 0

I had the following code before performing updates for Select All:

            "select": {
                "selector": 'td:first-child',
                "style":    'multi'
            }

This worked perfectly and only allowed the user to select the first column which contained my checkboxes.

I now have added a checkbox in the header area for my checkbox column to implement the select/deselect all. So far this is working great. But the new code is no longer respecting the td:first-child code and allows the user to click anywhere in the row for deselection. The problem with this is I am also using your details-control feature in the next column (so checkbox is column 0 and details-control is column 1).

Here is the new code:

            "select": 'multi'}).on( 'select.dt deselect.dt',  function (evtObj) {
               var all = table.rows().nodes().length;
               var sel = table.rows(".selected").nodes().length;

               if(all === sel){

                 $(".toggle-all").closest("tr").addClass("selected");
               }
               else{

                 $(".toggle-all").closest("tr").removeClass("selected");
               }

I am struggling with where to implement the td:first-child code so that the user is limited to still clicking the first column and now anywhere in the row for selection/deselection. Please advise. In the mean time, I will keep going in hopes of resolving my own issue.

Answers

  • pain19pain19 Posts: 57Questions: 5Answers: 0

    Fyi: I am using this full featured example as my guide: http://live.datatables.net/kuwaduta/193/edit

  • pain19pain19 Posts: 57Questions: 5Answers: 0

    I figured it out. I was trying to do too much inside of a code block. A simple addition of the following line worked for me:

    table.select.selector('td:first-child');

    This question can be closed by the moderator.

This discussion has been closed.