I am trying to insert three buttons in datatable

I am trying to insert three buttons in datatable

issamy11issamy11 Posts: 4Questions: 1Answers: 0

I am trying to insert 3 buttons after id="example_length" and I am stuck
I am using knockout js

<tbody
                        data-bind="dataTablesForEach: {data: $root.requests, dataTableOptions: {
                                    responsive : true,
                                   'language': {
                                        'search': 'Filter Companies:',
                                        'zeroRecords' : 'No Companies To Display'
                                    },  
                                    initComplete : function(){ 
                                    new $.fn.dataTable.Buttons(table, {
                                                                buttons: ['copy', 'excel', 'pdf'] }); 
                                    table.buttons().container().insertAfter( '#example_filter' );
                                    }
                              }
                          }">

Answers

  • allanallan Posts: 63,208Questions: 1Answers: 10,415 Site admin

    Thanks for your question - however, per the forum rules can you link to a test case showing the issue please. This will allow the issue to be debugged.

    Information on how to create a test page, if you can't provide a link to your own page can be found here.

    Thanks,
    Allan

  • issamy11issamy11 Posts: 4Questions: 1Answers: 0
    edited August 2016

    Thanks Allan for the quick response
    I am trying to use different approach

    <tbody
                            data-bind="dataTablesForEach: {data: $root.requests, dataTableOptions: {
                            dom : 'l<#toolbar>frtip',
                             
                                        responsive : true,
                                       'language': {
                                            'search': 'Filter Requests:',
                                            'zeroRecords' : 'No Requests To Display'
                                        }                                                                 
                                  }
                              }">
    

    Thanks Allan for the quick response
    I am trying to use different approach
    Is syntax is correct?
    I am trying to insert a div <#toolbar> after the length. I tried every possible way. I followed the documentation how to insert div with an id and class but in the DOM it only give me a empty div with a lenght label inside it.
    Thanks for your help.

    Edited by Allan - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.

  • allanallan Posts: 63,208Questions: 1Answers: 10,415 Site admin

    Is syntax is correct?

    I don't know I'm afraid. I'm not too familiar with Knockout. What does the generated HTML look like?

    As I say, please link to a test case.

    Allan

  • issamy11issamy11 Posts: 4Questions: 1Answers: 0
    edited August 2016

    Thanks Allan https://jsfiddle.net/z4zk9zdz/1/ I think when I try to add some functionality to datatable like buttons, sorting etc I think using $(document).ready(function() {
    $('#example').dataTable();
    });
    makes the data disappear and being not responsive

  • allanallan Posts: 63,208Questions: 1Answers: 10,415 Site admin

    You need to add the data to the table using the DataTables API - rows.add() in this case. At the moment you are adding data without telling DataTables, so it doesn't know that there is any data in the table.

    There are a number of threads on Knockout support with DataTables - for example. Basically you need to use a custom binding if you want to use it with DataTables.

    Allan

  • issamy11issamy11 Posts: 4Questions: 1Answers: 0

    Thanks Allan

This discussion has been closed.