Using Checkbox in client side data

Using Checkbox in client side data

omrcmomrcm Posts: 2Questions: 1Answers: 0

Hi,

I try to use checkbox in client side data. When I loop my data I'll not that datatable replace my 'checkbox' with his own. Is that possible?

Answers

  • kthorngrenkthorngren Posts: 20,264Questions: 26Answers: 4,764

    You can use your own checkbox. Please provide a link to your page or a test case showing the issue so we can offer suggestions.
    https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case

    Kevin

  • omrcmomrcm Posts: 2Questions: 1Answers: 0

    Hi Kevin,

    I have try it but was not success for creating a test case. Below you can see my sample code;

         <table class="datatable table striped hovered cell-hovered border bordered w-100 nowrap" id="order-table">
            <thead>
                <tr>
                    <th></th>
                    <th>Order id</th>
                    <th>Order Code</th>
                    <th>Deal id</th>
                    <th>Action</th>
                </tr>
            </thead>
            <tbody>
              <tr>
                <td> </td>
                <td>100</td>
                <td>AHY-2S</td>
                <td>K87-NHKJ</td>
              </tr>
              <tr>
                <td> </td>
                <td>100</td>
                <td>AHY-2S</td>
                <td>K87-NHKJ</td>
              </tr>
            </tbody>
          </table>
    
    
    <script>
           $(document).ready( function () {
    
                var table = $('#order-table-list').DataTable({
                    "processing": false,
                    "paging":   false,
                    "info":     false,
                    searching: false,
                    columnDefs: [{
                        targets: 0,
                        'orderable': false,
                        'checkboxes': {
                            'selectRow': true
                        }
                    }],
                    'select': {
                        style: 'multi'
                    }
                });
          });
    </script>
    
    

    My question is when I try to add "checkbox" datatables checkbox override it. Is that possible to use my own and not datatables.

  • colincolin Posts: 15,142Questions: 1Answers: 2,586

    checkboxes isn't a property of columnDefs. Please fix that, and provide a test case if you require further support. We're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.

    Cheers,

    Colin

  • kthorngrenkthorngren Posts: 20,264Questions: 26Answers: 4,764

    Actually checkboxes is the Gyrocode checkboxes plugin. If you don't want the plugin to generate the checkboxes then remove that part of the config. If you do that then you won't be able to use any of the APIs provided by the plugin. But you will be able to use all the APIs and events provided by the Select Extension.

    You can use columns.render to create your own checkboxes.

    If this doesn't help then we will need to see a test case so we can help and provide suggestions. If you are having difficulties with the test case provide the link and the problems you are having.

    Kevin

This discussion has been closed.