select only works with tabletools

select only works with tabletools

mmontoyammontoya Posts: 84Questions: 27Answers: 4

I am trying to use the examples given but the only way I can get select to work is to use TableTools (which I want to move to buttons but having trouble there, but that will be another post).

If I take out the TableTools section then select doesn't work, and the buttons don't show either with or without TableTools.

sidenote:
also, notice like 14 in the code below. I had to add a dummy value to my recordset, which I called myCheckbox. If I tried like the example "targets:0" I would get a tn\4 error for unknown parameter 0

          var tblNeedRA = $('#tblNeedRA').DataTable( {
              //jQueryUI: "true",
              //dom: "Tfrtp",
              lengthChange: false,
              autowidth: "false",
              ajax: "lib/getNeedRA.php",
              select: {
                  selector: 'td:first-child',
                  style: 'multi'
              },
              columns: [
                { orderable: false,
                  className: 'select-checkbox',
                  data: "myCheckbox"
                }
                ,{data: "CartonID"}
                ,{data: "RANumber"}
                ,{data: "OldRANumber"}
                ,{data: "OCNumber"}
                ,{data: "TrackingNumber"}
                ,{data: "ShipperName"}
                ,{data: "Qty"}
                ,{data: "LoadingDockReceiptDate"}
                ,{data: "AddedBy"}
              ],
              order: [[ 1, 'asc' ]],
"buttons": [
    {
        text: 'Select All',
        className: 'btn-success',
        action: function ( e, dt, node, config ) {
            alert( 'Button activated');
        }
    },
    {
        text: 'Deselect All',
        className: 'btn-success',
        action: function ( e, dt, node, config ) {
            alert( 'Button activated');
        }
    },
    {
        text: 'Refresh',
        className: 'btn-success',
        action: function ( e, dt, node, config ) {
            alert( 'Button activated');
        }
    }
]                              
          } );

          var tableTools = new $.fn.dataTable.TableTools( tblNeedRA, {
                    sRowSelect: "multi",
                } );
          $( tableTools.fnContainer() ).insertBefore( '#tblNeedRA' ); 

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 54,718Questions: 1Answers: 8,561 Site admin

    Can you link to a test page showing the issue with Select (without TableTools, since that is legacy software now).

    Thanks,
    Allan

  • mmontoyammontoya Posts: 84Questions: 27Answers: 4

    it is on a site that has a login. I can create a login for you and email it to you if you like

  • mmontoyammontoya Posts: 84Questions: 27Answers: 4

    I have sent you the link and login information.

    If you click 'Used RAs' select works using tableTools. If you click 'Need RA#, select does not work using buttons. If I uncomment the dom I get an error.

  • allanallan Posts: 54,718Questions: 1Answers: 8,561 Site admin

    Thanks for the e-mail.

    I believe the issue is that both Responsive and Select are trying to operate on the first column in the table. If I profile the page when clicking on the row, then I can see that Responsive handles the click request rather than Select.

    Could you try disabling Responsive on that table to see if that allows Select to work there? Its currently being added in the udsStyleGrid function.

    I would typically recommend that you have a different column for each of the two actions.

    Allan

  • mmontoyammontoya Posts: 84Questions: 27Answers: 4

    That didn't seem to help.

  • allanallan Posts: 54,718Questions: 1Answers: 8,561 Site admin
    Answer ✓

    Took me a while to figure out but the error is in how you are including the Select Javascript. Rather than using -tag script tag the code us using a link:

    <link rel="stylesheet" type="text/css" href="//cdn.datatables.net/select/1.1.0/js/dataTables.select.min.js">

    It should of course be a script element.

    Allan

  • mmontoyammontoya Posts: 84Questions: 27Answers: 4

    Oh my goodness. What a terribly copy and paste error I made. I would have never caught that.

    Thank you so much for your time. Now off to figure out how buttons work. I probably have some stupid error too.

  • mmontoyammontoya Posts: 84Questions: 27Answers: 4

    When looking in developer mode in Chrome I see the message: Cannot read property 'buttons' of undefined

  • allanallan Posts: 54,718Questions: 1Answers: 8,561 Site admin

    I don't see that error on the page link you gave me before.

  • mmontoyammontoya Posts: 84Questions: 27Answers: 4

    I got the error to go away (not sure what I changed), but the buttons don't show. I will post this separately as not to mix with this original issue.

    thanks

This discussion has been closed.