Are you the publisher? Claim or contact us about this channel


Embed this content in your HTML

Search

Report adult content:

click to rate:

Account: (login)

More Channels


Showcase


Channel Catalog


Channel Description:

Recent Discussions — DataTables forums

older | 1 | .... | 2317 | 2318 | (Page 2319) | 2320 | 2321 | .... | 2326 | newer

    0 0

    Iam firing an event to get API on the drawcallback after the datatable got data list. Also what i does that it keep check if current showed page has loaded and if the column data is loaded and column (say A) value is updated, it will sort accordingly by that column . Initially on datatable A column has value of zero.
    Below is the code which Iam using for sorting.
    let table = $('#comparison-table').DataTable();
    let page_order = table.order();
    table.order(page_order).draw(false);

    My issue is once i click the sorting icon, above code runs again after the order.dt events. So, is there a way to sort by only available data.


    0 0

    Hi Geek's

    I am new to the this DataTable Editor,

    Can anyone please help me how to create custom form when i click on button?

    I asked the same question for support but they telling to Purchase, without knowing all the customization how i can go with licence version.

    Thanks in advance


    0 0

    I'm using datatable editor with node.js and knex.js. When rendering a field ... I can add a options list to it like this:

    datatable editor node.js using knex.js :

    new Field('users.site')
        .options(new Options()
            .table('sites')
            .value('id')
            .label('name')
        );
    

    To access the json I can call the table and look for options:

    javascript:

    table_users.on( 'xhr', function () {
        var jsonOptions = table_users.ajax.json().options;
        console.log(jsonOptions);
    } )
    

    If I output it I get:

    console.log

    {…}
        "users.site": (4) […]
            0: Object { label: "A", value: "A" }
            1: Object { label: "B", value: "B" }
            2: Object { label: "C", value: "C" }
            3: Object { label: "D", value: "D" }
            length: 4
            <prototype>: Array []
            <prototype>: {…   
    

    ... but I'm not able to access the "users.site" array ... when I do this:

    table_users.on( 'xhr', function () {
        var jsonOptions = table_users.ajax.json().options;
        console.log(jsonOptions.users.site);
    } )      
    

    ... I'm getting an error in the console:

    TypeError: jsonOptions.users is undefined
    

    Obviously I can call jsonOptions.users.site ... but how can I access those values? Can I rename the options access key for instance? (If its possible to change the key name ... I would only want to change it for the options key ... not for the column key though if possible.)


    0 0

    Using version 1.10.19. Tried with plain numbers as well.
    Rows are sorted ok except the ones with values beyond 999.999,00

    var dtnc = $("#dt-propiedades-listar").DataTable(
    // Opciones
    {
    "ajax": '/path/',
    "processing": true,
    "paging": true,
    "deferRender": true,
    "columns": [
    {"data": "select"},
    {"data": "imagenes"},
    {"data": "referencia"},
    {"data": "propiedad_provincia"},
    {"data": "propiedad_localidad"},
    {"data": "propiedad_subtipo"},
    {"data": "habitaciones_totales"},
    {"data": "banios_totales"},
    {"data": "metros_totales"},
    {"data": "venta_precio"},
    {"data": "alquiler_precio"},
    {"data": "temporada_precio"},
    {"data": "traspaso_precio"},
    {"data": "modificado"},
    {"data": "visible"},
    {"data": "disponible"},
    {"data": "compartido"},
    {"data": "links"}
    ],
    "select": {
    style: 'multi',
    selector: 'td:first-child input',
    blurable: false,
    className: 'selected'
    },
    "stateSave": true,
    "language": {
    "url": "//cdn.datatables.net/plug-ins/1.10.16/i18n/Spanish.json"
    },
    "columnDefs": [
    {
    "targets": 0,
    "searchable": false,
    "sortable": false

                },
                {
                    "targets": 1,
                    "searchable": false,
                    "sortable": false
    
                },
                {
                    "targets": 6,
                    "className": "text-right"
                },
                {
                    "targets": 7,
                    "className": "text-right"
                },
                {
                    "targets": 8,
                    "className": "text-right"
                },
                {
                    "targets": 9,
                    "className": "text-right",
                    "type": "num-fmt"
                },
                {
                    "targets": 10,
                    "className": "text-right",
                    "type": "num-fmt"
                },
                {
                    "targets": 11,
                    "className": "text-right",
                    "type": "num-fmt"
                },
                {
                    "targets": 12,
                    "className": "text-right",
                    "type": "num-fmt"
                },
                {
                    "targets": -1,
                    "searchable": false,
                    "sortable": false
                },
                {
                    "targets": -2,
                    "className": "text-right"
                },
                {
                    "targets": -3,
                    "searchable": false,
                    "className": "text-right"
                },
                {
                    "targets": -4,
                    "searchable": false,
                    "className": "text-right"
                },
                {
                    "targets": -5,
                    "searchable": false,
                    "className": "text-right"
                }],
            "order": [[2, "desc"]],
            "rowCallback": function (row, data) {
                // Set the checked state of the checkbox in the table
                $('input.selectRow', row).prop('checked', data.active == 1);
            },
            "initComplete": function () {
                load_quick_view();
            }
        }
    

    0 0

    How do I correctly order a option value? This doesn't seem to work:

    new Field('users.site')
        .options(new Options()
            .table('sites')
            .value('id')
            .label('name')
            .order(desc)
        );
    

    0 0

    Hi guys,

    I would like to avoid another generic "how to speed up DT" question, so I'll be as specific as possible.

    My DT has ~5000 rows and takes 9 seconds to load with a basic broadband connection. That's mostly because of the 5mb JSON file behind it.

    I find this fast in my own typical use, but when I've shown it others, they became impatient, even if later load times (searching) are negligible.

    Is there a good way to make the initial load time faster?

    I read a few threads about server-side processing and they seem to involve SQL, which is an extra layer of complication for me. All I think I need in that situation is simply a PHP that processes the ajax calls and passes the data from JSON (also protecting it in the process from being saved in the clientes — bonus points).

    What is everyone else doing?

    Thanks


    0 0

    I'm trying to figure out if this is possible. When a user scrolls up or down the datatable the following is always visible at the head...


    0 0
  • 01/12/19--16:24: Changelog for Buttons 1.5.4
  • I see that Buttons 1.5.4 has been out for a while on npm but there is no changelog entry at https://cdn.datatables.net/buttons/.
    I can see the code changes here: https://github.com/DataTables/Buttons/compare/1.5.3...1.5.4
    but it would be nice to have a list of what was changed.


    0 0

    I just want a simple select like this in my datatables server-side column:

                     <select id = "myList">
                                   <option value = "1">1</option>
                                   <option value = "2">2</option>
                                   <option value = "3">3</option>
                                 </select>
    
       <script type="text/javascript"> 
        $(document).ready(function() {
           var table=  $('#example').DataTable( {
                "processing": true,
                "serverSide": true,
                ajax: {
                url: 'server.php',
                type: 'POST',
                },
             columnDefs: [
              {  targets: -1,
                 render: function (data, type, row, meta) {
                    return '<button type="submit" class="add_btn btn btn-success btn-md active" data-id="' + meta.row + '"  id=" ' + meta.row + ' " value="add">  <span class="glyphicon glyphicon-plus"></span> </button>';
                 }
              }
              ],
          columnDefs: [ {
                    "targets": -2,
                    "render": function (data, type, row, meta){
                                            var $select = $("<select></select>", {
                                            });
                                            $.each(times, function (k, v) {
    
                                                var $option = $("<option></option>", {
                                                    "text": v,
                                                    "value": v
                                                });
                                                if (data === v) {
                                                    $option.attr("selected", "selected")
                                                }
                                                $select.append($option);
                                            });
                                            return $select.prop("outerHTML");
                 }
                } ],
            })
        } ); // end ready
        </script>
    

    Project link if needed: https://sampleajax.000webhostapp.com/


    0 0

    i have problem in datatable.
    after reload datatable This error occurs..
    im destroying datatable before reload

    Uncaught TypeError: Failed to set an indexed property on 'HTMLSelectElement': The provided value is not of type 'HTMLOptionElement'.
    at ob (jquery.dataTables.min.js:50)
    at nb (jquery.dataTables.min.js:32)
    at ha (jquery.dataTables.min.js:48)
    at e (jquery.dataTables.min.js:93)
    at b (jquery.dataTables.min.js:73)
    at Jb (jquery.dataTables.min.js:74)
    at HTMLTableElement.<anonymous> (jquery.dataTables.min.js:93)
    at Function.each (jquery-3.3.1.min.js:2)
    at w.fn.init.each (jquery-3.3.1.min.js:2)
    at w.fn.init.n [as dataTable] (jquery.dataTables.min.js:83)


    0 0

    Hi!

    I use a datatable with links to another pages on my site. If you use the browsers "return" function the table shows again page number one. Is it possible to remember where you linked out (e.g. from page 5)

    Thanks!

    Joerg


    0 0

    I use Yahoo YQL to bypass some iframe CORS request and they seem to have shut down this service.
    I want to know if there is any alternative out there or a self hosted option.

    My query goes like this:
    https://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20data.headers%20where%20url%3D%22about%3Ablank%22&format=json&diagnostics=true&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys&callback=getData


    0 0

    Good afternoon everybody!

    Before trying to get mad doing something that may not be possible, I came where with my doubt based on this requirement:

    When I change a field, entire row must be sent to the server in order to make a full row validation there.
    Could I be able to:

    • If the field I have changed is the filed of the error in fieldErrors object: editor is still open, with the edited value and the error message behind
    • If the field that's giving error is not the field I have changed when I sent the information, could I open the editor there, with the error message behind?
    • If there are more than one error: could I put the error message behind each field?

    Thanks in advance!


    0 0

    My datatable is not refereshing after I make the edit. My database is getting changed. Server is replying with the data parameter defining the data object for the edited row. Couldnt identify the issue. Plz help.

    here goes my whole script

    /* Formatting function for row details */
    function format ( d ) {
        // `d` is the original data object for the row
        return '<table cellpadding="5" cellspacing="0" border="0" style="padding-left:50px;">'+
            '<tr>'+
            '<td>Source:</td>' +
            '<td>' + d.referred_by + '</td>' +
            '<td>Address:</td>' +
            '<td>' + d.lead_address + '</td>' +
           
        '</tr>' +
        '<tr>' +
        '<td>Status</td>' +
        '<td>' + d.lead_status + '</td>' +
            '<td>Remarks:</td>' +
            '<td>' + d.other_info + '</td>' +
        '</tr>' +
        '<tr>'+
        '<td>Presented By:</td>' +
        '<td>' + d.other_info2 + '</td>' +
        '<td></td>' +
        '<td></td>' +
    '</tr>' +
        '</table>';
    }
    var editor;
    $(document).ready(function() {
        
         var editor = new $.fn.dataTable.Editor( {
            ajax:  '/testing/editLeadsJson',
            table: '#leads',
            idSrc: 'lead_id',
            fields: [
                { label: 'ID', name: 'lead_id' },
                { label: 'NAME', name: 'lead_name' },
                { label: 'CONTACT',  name: 'lead_number1'  },
                { label: 'AREA',  name: 'lead_area'  },
                { label: 'BUSINESS NAME ',  name: 'lead_buss_name'  },
                { label: 'NATURE OF BUSINESS',  name: 'lead_category'  },
                { label: 'APPOINTMENT-DATE',  name: 'app_date'  },
                { label: 'APPOINTMENT-TIME',  name: 'app_time'  },
                { label: 'LEAD ASSIGNED',  name: 'agent_assigned'  },
                { label: 'Agent',  name: 'lead_telecaller'  },
                { label: 'SOURCE',  name: 'referred_by'  },
                { label: 'Address',  name: 'lead_address'  },
                { label: 'Remarks',  name: 'other_info'  },
                { label: 'Status',  name: 'lead_status'  },
                { label: 'Presented by',  name: 'other_info2'  }
                // etc
            ]
        } ); 
        // Activate an inline edit on click of a table cell
               $('#leads').on( 'dblclick', 'tbody td.editable', function (e) {
            editor.inline( this, {
                submit: 'allIfChanged',
                submitOnBlur: true
            } );
        } );
         var table = $('#leads').DataTable({
             ajax: {
                    "url": '/testing/readLeadsJson',
                    "dataSrc": ""
                }, 
             stateSave: true,
             select: {
                    style:    'multi',
                    selector: 'td:not(:first-child)'
                }, 
             columns: [ 
             {
                className:      'details-control',
                orderable:      false,
                data:           null,
                defaultContent: ''
             },
             {
                 className: 'select-checkbox',
                 orderable: false,
                 data:           null,
                 defaultContent: ''
             },
             { 
             "data" : "lead_id",
                "className" : "text-center"
            },
            {
                "data" : "lead_name",
                "className" : "text-center editable"
            },
            {
                "data" : "lead_number1",
                "className" : "text-center editable"
            },
            {
                "data" : "lead_area",
                "className" : "text-center editable"
            },
            {
                "data" : "lead_buss_name",
                "className" : "text-center editable"
            },
            {
                "data" : "lead_category",
                "className" : "text-center editable"
            },
            {
                "data" : "app_date",
                "className" : "text-center editable"
            },
            {
                "data" : "app_time",
                "className" : "text-center editable"
            },
            {
                "data" : "agent_assigned",
                "className" : "text-center editable"
            },
            {
                "data" : "lead_telecaller",
                "className" : "text-center editable"
            },
             { 
                 "data": "referred_by",
                 "visible": false,
                 "searchable": true
             },
             { 
                 "data": "lead_address",
                 "visible": false,
                 "searchable": true
             },
             { 
                 "data": "other_info",
                 "visible": false,
                 "searchable": true
             },
             { 
                 "data": "other_info2",
                 "visible": false,
                 "searchable": true
             }
             ] ,
             pageLength: 50,
             orderCellsTop: true,
             fixedHeader: true,
             lengthMenu: [[10, 25, 50, 100, 500, -1], [10, 25, 50, 100, 500, "All"]],
             dom: 'Bfirtlip',
             buttons: [
                 'excel', 'pdf', 'copy', 
                 {
                    text: 'Expand All',
                    action: function(){
                         // Enumerate all rows
                         table.rows().every(function(){
                             // If row has details collapsed
                             if(!this.child.isShown()){
                                 // Open this row
                                 this.child(format(this.data())).show();
                                 $(this.node()).addClass('shown');
                             }
                         });
                    }
                 },
                 {
                    text: 'Collapse All',
                    action: function(){
                         // Enumerate all rows
                         table.rows().every(function(){
                             // If row has details expanded
                             if(this.child.isShown()){
                                 // Collapse row details
                                 this.child.hide();
                                 $(this.node()).removeClass('shown');
                             }
                         });
                     }
                 },
                 { extend: "edit",   editor: editor }
             ]
        });
         
         // Show all child nodes
            table.rows().every( function () {
                this.child(format(this.data())).show();
                this.nodes().to$().addClass('shown');
            });  
         // Add event listener for opening and closing details
            $('#leads tbody').on('click', 'td.details-control', function () {
               var tr = $(this).closest('tr');
               var row = table.row( tr );
          
               if ( row.child.isShown() ) {
                  // This row is already open - close it
                  row.child.hide();
                  tr.removeClass('shown');
               }
               else {
                  // Open this row
                  row.child( format(row.data()) ).show();
                  tr.addClass('shown');
               }
            } );
         // Restore state
            var state = table.state.loaded();
            if ( state ) {
              table.columns().eq( 0 ).each( function ( colIdx ) {
                var colSearch = state.columns[colIdx].search;
                
                if ( colSearch.search ) {
                  $( 'input', table.column( colIdx ).footer() ).val( colSearch.search );
                }
              } );
            }
    } );
    

    The response from the server is

    [{"data":[{"action":null,"agent_assigned":"","app_date":"23 dec","app_time":"10","last_action_at":null,"last_action_by":null,"lead_address":"ch","lead_area":"wsx","lead_buss_name":"M C","lead_category":"Insurance Consultants","lead_id":1,"lead_name":"test","lead_number1":"123","lead_status":null,"lead_telecaller":"Navin","other_info":"test","other_info2":null,"referred_by":"Vendors "},{"action":null,"agent_assigned":null,"app_date":"Call Bak - Jan'19","app_time":null,"last_action_at":null,"last_action_by":null,"lead_address":"No 480, NSC Boss Road, Kondithope-Sowcarpet, Chennai - 600001, Near Amman Temple","lead_area":"Sowcarpet","lead_buss_name":"Jain Jewellery","lead_category":"Jewellers","lead_id":2,"lead_name":null,"lead_number1":"9994790708","lead_status":null,"lead_telecaller":"Navin","other_info":null,"other_info2":null,"referred_by":"Jain Vendors "},{"action":null,"agent_assigned":null,"app_date":"Shop Closed","app_time":null,"last_action_at":null,"last_action_by":null,"lead_address":"Nirmal Plaza, Shop No 4, Ground Floor, 159, Mint Street, Sowcarpet, Chennai - 600001, Near Kakada Sweets","lead_area":"Sowcarpet","lead_buss_name":"Jain Silver","lead_category":"Jewellers\/Silver","lead_id":3,"lead_name":null,"lead_number1":"25360510\/9176351688","lead_status":null,"lead_telecaller":"Navin","other_info":null,"other_info2":null,"referred_by":"Jain Vendors "}]}]
    

    0 0

    I'm trying to set value to header <th></th> where the input type is text. When I removed the "scrollX": true, or changed it to "scrollX": false, in the DataTable. It works as expected when I click the row, the details will show in the th.

    Below is the live sample data with "scrollX": true,
    live.datatables.net/masoguma/1/

    Below is the live sample data without "scrollX": true, or "scrollX": false,
    live.datatables.net/riviroqi/1/

    I need the scrollX because I have a more than 30 columns.


    0 0
  • 01/11/19--00:37: Use htmlentities with editor
  • Hi,
    For reasons, I need all editor input to go through htmlentities($string,ENT_QUOTES,'UTF-8');
    I know I can do it manually and edit each and every one of my fields set function callbacks but this means 100+ fields to go through. is there a way to automatically convert ALL data that is going to the SQL using htmlentities? so that instead of " in the database I will have &qoute;?


    0 0

    I modified the range_dates.js plugin to parse and filter ISO 8601 dates (yyyy-mm-dd).

    I have created a test case at:
    http://live.datatables.net/nuxasuxa/2

    To replicate the issue:
    1. Select Start Date == 2018-12-01. Immediately all records are filtered out, but all 15 should display.
    2. Select End Date == 2018-12-25. All records remain filtered out, but 8 records should display.
    3. Tab back and forth through Search Record Name and End Date. 8 records will hide and display, but 8 records should display.
    4. Repeat Steps 1 and 2, but type the date manually to experience the same issue.
    5. Remove the datepicker initialization, and repeat Steps 1 and 2 to experience the same issue.

    I've tried changing events between keyup, change, blur, focus, etc., but that had no effect.

    How can I fix this UI issue?


    0 0

    When i save a row that i edited, it jumps back to page 1.
    stateSave is enabled and it works with reloading but not when i save something


    0 0

    As the user change a field, I need another field to be updated.
    It works well using a listener in the edition form:

    $( 'input', editor.field( 'ds_pluv' ).node() ).on( 'change', function (e, d) {
    if ( ! d || ! d.editor ) { // Used to be sure change is fired from the form (not inline editing)
    editor.field( 'ds_cor_pluv' ).val(true);
    }
    } );

    But when inline editing, this appears not to be working.
    Is there any other way to be able to trigger a specific action after inline editing a cell ?

    Xavier


    0 0

    For the editor that I am using, only certain fields show if they are enabled in the setting page. I am unsure of how to make them required when they aren't hidden. I've tried on the editor have the attr part and make the field required set to true, however it doesn't seem to do anything as I can leave it empty and it still submits the values to the database. Its only in the server side script when I use a validator::notEmpty it makes it required. However it should validate only when the field isn't empty. Is there a way in the server side script to check what the field type is?


older | 1 | .... | 2317 | 2318 | (Page 2319) | 2320 | 2321 | .... | 2326 | newer