Quantcast
Channel: Recent Discussions — DataTables forums

problem with OrderFixed on a complex DT (row group, responsive, etc)

$
0
0

Link to test case: https://live.datatables.net/xoqasoga/16/edit
Debugger code (debug.datatables.net):
Error messages shown:
Description of problem:

Hi,

I Have 3 problems/questions on a DT 2.0 with rowgroup (responsive and other extensions)

1) Problem width OrderFixed

I've created a test case with (almost) real data, but the output doesn't work and I don't find the reason why.
So I've put screenshot to try to explain.
At least, you can see the JS content here :
https://live.datatables.net/xoqasoga/16/edit

If I add a fixed order on the column Date with orderFixed: [2, 'desc'].

This is how the table look like :
- the fixed order is good
- a triangle is showing at the top of the column 0 (it doesn't happen with an order « not fixed » order: [2, 'desc'])
- sorting the other columns doesn't work anymore (it doesn't happen with an order « not fixed » order: [2, 'desc'])

This is part of the DT code :

        orderFixed: [2, 'desc'], // tri fixe pour la rupture (dateDebut)
        responsive: {
            details: {
                type: 'column',
                target: 'tr',
                renderer: function (api, rowIdx, columns) {
                    var data = $.map(columns, function (col, i) {
                        return col.hidden
                            ? '<p class="has-text-grey px-2 py-2"><span class="has-text-weight-semibold smallcaps">'+ col.title + ' : </span>' + col.data + '</p>'
                            : '';
                        }).join('');
                    return data ;
                }
            }
        },
        rowGroup: {
            dataSrc: 'dateDebut.annee', // groupe pour rupture
            startClassName: 'rupture has-text-' + interfaceBB, 
            endClassName: 'soustotal has-text-' + interfaceBB, 
            startRender: function ( rows, group ) {
                return 'IMMOBILISATIONS ' + group + '<span class="is-pulled-right">('+rows.count()+')</span>';
            },
            endRender: function (rows, group) {
                
                // sous-totaux par groupe 
                
                var subtotalAchat =
                    rows
                        .data()
                        .pluck('Montant1')
                        .reduce(function (a, b) {
                            return a + b * 1;
                        }, 0) ;

                var subtotalCession =
                    rows
                        .data()
                        .pluck('Montant2')
                        .reduce(function (a, b) {
                            return a + b * 1;
                        }, 0) ;

                subtotalAchat = DataTable.render.number(' ', ',', 2, null, '').display(subtotalAchat);
                subtotalCession = DataTable.render.number(' ', ',', 2, null, '').display(subtotalCession);

                return $('<tr/>')
                .append('<td colspan="10" class="has-text-right has-text-weight-semibold">TOTAL ' + group + ' (' + rows.count() + ')</td>')
                .append('<td class="has-text-right has-text-weight-semibold">' + subtotalAchat + '</td>')
                .append('<td></td>')
                .append('<td class="has-text-right has-text-weight-semibold">' + subtotalCession + '</td>')
                .append('<td></td>');
            }
        }

2) Rowgroup & Responsive : How counting the <td> ?

In the same DT, with RowGroup I'm adding subtotals for each group, and a global total as you can see on the capture below.

But the DT is responsive and I don't know how I could count the visible <td> to add the good value in the colspan in the subtotal in the endRenderof rowgroup.

I don't have the problem with the footerCallbackfor the global total because the JS code is different.

Here, the subtotals have the right value in colspan because all columns are visible :

Here, the window is smaller, some columns on the right are hidden and the subtotals <tr> doesn't look good (because of my code !) To be perfect, I should change the colspan and also hide the same columns) :

3) FixedHeader, alignement problems

As you can see on the last 2 screenshots, the title columns in the fixed header doesn't have the same width of the content <td>.
I thought this problem was solved in DT 2.0.
Maybe, I should change something in my JS or HTML code ?

Thank you for your patience reading this long message (full of typos) and your help


I have purchased the Editor license almost 2 months. I still can't figure out how to use.

$
0
0

Hi,

I have already purchased the Editor license (one developer) for almost 2 months. I can't even list the Table as before. It just feezed on screen. I still can't figure out how I can make use of the Editor for inline editing. Can I send in the programs for checking and advise?

Keith Wong

Set column (max) width

$
0
0

I'm looking for a way to set the max width or width of a single column in a DataTable.
I tried "columnDefs width" but this did not affect the width of the column.

This is the configuration of DataTables I'm using: https://datatables.net/download/#bs5/jszip-2.5.0/dt-1.11.3/b-2.0.1/b-colvis-2.0.1/b-html5-2.0.1/b-print-2.0.1/cr-1.5.4/r-2.2.9
Maybe "columnDefs " does not work with the Responsive plugin?
Is there another way to set the max-width or width of a column.

How my table currently looks (the last column is far too wide):

The code used to create the table:

{
    "language": {
        "aria": {
            "sortAscending": ": aktivieren, um Spalte aufsteigend zu sortieren",
            "sortDescending": ": aktivieren, um Spalte absteigend zu sortieren"
        },
        "emptyTable": "Keine Daten vorhanden",
        "info": "_START_ bis _END_ von _TOTAL_ Einträgen",
        "infoEmpty": "0 bis 0 von 0 Einträgen",
        "infoFiltered": "(gefiltert von _MAX_ Einträgen)",
        "lengthMenu": "_MENU_ Einträge anzeigen",
        "loadingRecords": "Wird geladen...",
        "paginate": {
            "first": "Erste",
            "last": "Letzte",
            "next": "Nächste",
            "previous": "Zurück"
        },
        "processing": "<div class='processingWrapper hidden-print'><i class='far fa-spinner fa-spin'></i><p>Bitte warten...</p></div>",
        "search": "Suchen",
        "zeroRecords": "Keine Einträge vorhanden.",
        "thousands": ".",
        "infoPostFix": "",
        "decimal": ""
    },
    "stateSave": true,
    "stateDuration": 604800,
    "lengthMenu": [
        [
            10,
            20,
            50,
            100,
            500
        ],
        [
            "10",
            "20",
            "50",
            "100",
            "500"
        ]
    ],
    "pageLength": 10,
    "processing": true,
    "responsive": true,
    "ajax": {
        "url": "/AdvertisementCampaign/GetAtmGroupsOfCampaign?advertisementCampaignId=4",
        "type": "POST"
    },
    "columns": [
        {
            "name": "Id",
            "orderable": false,
            "visible": true,
            "responsivePriority": 10000,
            "render":renderIdColumn,
            "useAsGroupingColumn": false,
            "data": "Id",
            "searchable": false
        },
        {
            "name": "Name",
            "orderable": true,
            "visible": true,
            "responsivePriority": 10000,
            "useAsGroupingColumn": false,
            "data": "Name",
            "searchable": true
        },
        {
            "name": "Description",
            "orderable": true,
            "visible": true,
            "responsivePriority": 10000,
            "useAsGroupingColumn": false,
            "data": "Description",
            "searchable": true
        }
    ],
    "serverSide": true,
    "order": [
        [
            1,
            "asc"
        ]
    ],
    "dom": "<'dt-toolbar'<'container-fluid'<'row'<'col-xs-12 col-sm-6 col-md-3 dataTableToolBarLeft hidden-print'l><'col-xs-12 col-sm-6 col-md-9 hidden-print dataTableToolBarRight'BT>>>>tr<'dt-toolbar-footer'<'container-fluid'<'row'<'col-md-4 col-lg-4 d-none d-md-block'i><'col-sm-12 col-md-8 col-lg-8 hidden-print pull-right'p>>>>",
    "buttons": {
        "dom": {
            "button": {
                "className": "btn"
            },
            "buttonLiner": {
                "tag": null
            }
        },
        "buttons": [
            {
                "dom": {
                    "button": {
                        "className": "btn"
                    },
                    "buttonLiner": {
                        "tag": null
                    }
                },
                "text": "Drucken",
                "extend": "print",
                "className": "btn-outline-primary dt-btn-action d-none d-md-block",
                "autoClose": true,
                "exportOptions": {
                    "columns": ":visible.export",
                    "format": {
                        "header":window.LsDataTables.getColumnTitle
                    }
                },
                "orientation": "landscape",
                "pageSize": "LEGAL"
            },
            {
                "dom": {
                    "button": {
                        "className": "btn"
                    },
                    "buttonLiner": {
                        "tag": null
                    }
                },
                "text": "Kopieren",
                "extend": "copyHtml5",
                "className": "btn-outline-primary dt-btn-action",
                "autoClose": true,
                "exportOptions": {
                    "columns": ":visible.export",
                    "format": {
                        "header":window.LsDataTables.getColumnTitle
                    }
                },
                "orientation": "landscape",
                "pageSize": "LEGAL"
            },
            {
                "dom": {
                    "button": {
                        "className": "btn"
                    },
                    "buttonLiner": {
                        "tag": null
                    }
                },
                "text": "Exportieren",
                "extend": "collection",
                "className": "btn-outline-primary dt-btn-action",
                "autoClose": true,
                "orientation": "landscape",
                "pageSize": "LEGAL",
                "buttons": [
                    {
                        "dom": {
                            "button": {
                                "className": "btn"
                            },
                            "buttonLiner": {
                                "tag": null
                            }
                        },
                        "text": "CSV",
                        "extend": "csvHtml5",
                        "className": "btn-outline-primary",
                        "autoClose": true,
                        "exportOptions": {
                            "columns": ":visible.export",
                            "format": {
                                "header":window.LsDataTables.getColumnTitle
                            }
                        },
                        "orientation": "landscape",
                        "pageSize": "LEGAL"
                    },
                    {
                        "dom": {
                            "button": {
                                "className": "btn"
                            },
                            "buttonLiner": {
                                "tag": null
                            }
                        },
                        "text": "Excel",
                        "extend": "excelHtml5",
                        "className": "btn-outline-primary",
                        "autoClose": true,
                        "exportOptions": {
                            "columns": ":visible.export",
                            "format": {
                                "header":window.LsDataTables.getColumnTitle
                            }
                        },
                        "orientation": "landscape",
                        "pageSize": "LEGAL"
                    }
                ]
            },
            {
                "dom": {
                    "button": {
                        "className": "btn"
                    },
                    "buttonLiner": {
                        "tag": null
                    }
                },
                "extend": "reload",
                "className": "btn-outline-primary dt-btn-action",
                "autoClose": true,
                "orientation": "landscape",
                "pageSize": "LEGAL"
            }
        ]
    }
}

DataTable.render.select is not a function...and inline editing not working

$
0
0

Trying to replicate the simple inline editing example (https://editor.datatables.net/examples/inline-editing/simple.html) with my own application. But I just get this error on loading, no select checkbox is shown, and nothing happens when I click in a table cell. I must be missing something somewhere! NB this is with DataTables 1.13 and Select 1.7.0, JS and CSS files generated to include Select etc. Any help welcome. Thanks.


jQuery.Deferred exception: DataTable.render.select is not a function

Here is my JS:

 var appeditor = new DataTable.Editor({
            ajax: "php/table.TApplicationsSpreadsheet.php",
            fields: [
                {"label": "id", "name":"id"},
               ..... more columns
            ], table: "#sheet"
        });

 var spreadsheetTable = new DataTable('#sheet', {
            ajax: 'php/table.TApplicationsSpreadsheet.php',
            columns: [
               { "data": 
               null,orderable: false,
               render: DataTable.render.select()},

                {
                    "data": "id", "label":"ID"
                }

             ... more columns.....
            ],
            layout: {
                topStart: {
                    buttons: [
                        { extend: 'create', editor: appeditor },
                        { extend: 'edit', editor: appeditor },
                        { extend: 'remove', editor: appeditor }
                    ]
                }
            },
            scrollY: "500px",
            "paging": false,
            "autoWidth": false,
            order: [[1, 'asc']],
            select: {
                style: 'os',
                selector: 'td:first-child'
            }
            }
        );

        // Activate an inline edit on click of a table cell
        $('#sheet').on('click', 'tbody td:not(:first-child)', function (e) {
            appeditor.inline(this);
        });

HTML:

<div class="container" style="width:90%; padding-left: 70px">
    <table cellpadding="0" cellspacing="0" border="0" class="table table-striped table-bordered" id="sheet" >
                <thead>
                    <tr>


                        <th></th>
                        <th>ID</th>
                        ...more columns...

                    </tr>
                </thead>
    </table>
</div>

CSS and JS imports:

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
        <link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/v/bs/jq-3.7.0/moment-2.29.4/dt-1.13.8/b-2.4.2/date-1.5.1/sl-1.7.0/datatables.min.css">

        <link rel="stylesheet" type="text/css" href="css/editor.bootstrap.min.css">
        <link rel="stylesheet" type="text/css" href="css/table.css">


        <script type="text/javascript" charset="utf-8" src="https://cdn.datatables.net/v/bs/jq-3.7.0/moment-2.29.4/dt-1.13.8/b-2.4.2/date-1.5.1/sl-1.7.0/datatables.min.js"></script>
        <script src="https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
        <script type="text/javascript" charset="utf-8" src="js/dataTables.min.js"></script>



        <script type="text/javascript" charset="utf-8" src="https://cdn.datatables.net/datetime/1.5.1/js/dataTables.dateTime.min.js"></script>
        <script type="text/javascript" charset="utf-8" src="https://cdnjs.cloudflare.com/ajax/libs/jquery.mask/1.14.0/jquery.mask.js"></script>
        <script type="text/javascript" charset="utf-8" src="js/editor.mask.js"></script>
        <script type="text/javascript" charset="utf-8" src="js/table.TApplicationsSpreadsheet.js"></script>

Need help converting to new layout from dom.

$
0
0

Old (borrowed from https://github.com/DataTables/DataTables/blob/master/media/js/dataTables.bootstrap4.js#L48):

    const BS4DOM = "<'row'<'col-sm-6 col-md-12'<'#buttonContainer'>>>" +
      "<'row'<'col-sm-12'tr>>" +
      "<'row'<'col-sm-12 col-md-5'i><'col-sm-12 col-md-7'p>>";

Is there an easy migration for the above? All of my pages use a helper function like so:

    function AppendButtons(table, buttonGroupSelector) {
      table
        .buttons(buttonGroupSelector, null)
        .container()
        .appendTo('#buttonContainer');

Export making use of data-* attribute

$
0
0

In our Datatables we sometimes show icons instead of text value, for example a check/cross symbol indicating "yes"/"no". Of course, these symbols are not going to be exported, but I am looking for an easy way to export the text instead.

To be more precise, I would like to add the export text as a data attribute to the table cell:
<td data-order="yes" data-export="yes"><i class="fa fa-check"></i></d>

I tried to use both the documented data-order and the "undocumented" data-export attribute (which has been used in some examples) with exportOptions: { orthogonal: 'order' } and exportOptions: { orthogonal: 'export' } respectively, but the column remains empty in my Excel file.

My question is similar to this one, however it is not clear to me if I have to use the format function to achive this or do I have an error in my code and it should be working to use the data-* attribute?

I also wonder if it would be a good built-in functionality to have an official orthogonal data-export attribute?

Datatables cannot display my data

$
0
0

I ajax load my generated data using dynamically created columns, I tested for both the column and data objects, they look fine but my data still not displayed, what is wrong?

Here is the column object.

Here is the data object.

And here is the table showing nothing!

Here is the script I use:

$(document).ready(function(){
    $("#process").click(function(){
    var tableColumns = []; 
    $('#result').dataTable({
        destroy: true,
        responsive: true,
        ordering: false,
        stateSave: true,
        deferRender: true,
        ajax: {
            url: "process/",
            type: "POST",
            dataSrc: function(d) {
            heads = Object.keys(d.data[0]);
            for (var i in heads) {
                tableColumns.push({ 
                    data: heads[i],
                    title: heads[i][0].toUpperCase()+heads[i].slice(1)
                });
            }
            console.log(d.data);
            return d.data
            },
        },
        columns: tableColumns,
        layout: {
            topStart: {
                buttons: [
            {extend: 'copyHtml5', text:'<i class="fa fa-files-o"></i>', titleAttr: 'Copy'},
            {extend: 'csv', text: 'CSV'},
            {extend: 'excel', text: 'Excel'},
            {extend: 'pdf', text: 'PDF', exportOptions: {columns: ':visible'},                    
            customize: function (doc) {
            doc.defaultStyle.fontFamily = 'Arial';
            doc.defaultStyle.fontSize = 10;}},
            {extend: 'print',text: 'Print'},
            {extend: 'colvis',text: 'View'},
            {extend: 'pageLength',text: 'Length'}
            ]},
            topEnd: {
                search: {
                    placeholder: 'Type search here'
                }
            },
            bottomEnd: {
                paging: {
                    numbers: 5
                }
            }
        },
    });

});
});

How to select (and copy) a column name?

$
0
0

Hi Allan, I would like to know if it is possible to reduce the size of the ordering button in the table header to allow the column names to be selected (e.g. double click as we do for text) and copied (e.g. Ctrl+C) ?

That is in the context of ITables, where we write Python code to display a table, then look at the table, and use the output to edit the Python code, often adding conditions that involve the columns names.

I looked into this in the past at https://github.com/mwouts/itables/issues/227, and found that setting orderable=False on the columns was one way to do it, but ideally I would prefer to be able to both sort and still copy the column name.


How to use fixed header, table scrollbar and filter column at a time

Remove button message Bootstrap5 not showing correctly.

$
0
0

i was trying to add a delete button using this example here and when you set the styling to Bootstrap5 it shows a message in the bottom left of the screen and not in a model. i am getting the same behavior on my stuff as well.

Stop printing hidden hidden rows

$
0
0

im working on this script for selecting some rows to show only , but when try to print the table , it print all rows the visible and hidden , how to stop printing hidden rows , i tryed this but not working .

$(document).ready(function () {
var table = $('#register').DataTable({
sort: [[4, 'asc']],
dom: 'Bfrtip',
bInfo: false,
buttons: [
{
extend: 'excel',
exportOptions: {
// Exclude the last column
columns: ':not(:last)'

              }
          },
          {
              extend: 'print',
              exportOptions: {
                  // Exclude the last column
                  columns: ':not(:last)',


              },
              customize: function (win) {
                  $(win.document.body).find('tr:hidden').remove();

                  $(win.document.body)
                      .css('font-size', '10pt')
                      .prepend(
                          '<div id="header" style="text-align: center;">' +
                          '<img src="/Images/charmillion_logo.jpeg" style="max-width: 100%; height: auto; width: 200px;" />' +
                          '</div>'
                      );

                  $(win.document.body).find('table')
                      .addClass('compact')
                      .css('font-size', 'inherit');
              },
          },
          'colvis',  
          'pageLength'
      ],

      columnDefs: [
          {
              targets: 5,
              data: 'LostStage.StageName',
              render: function (data, type, row) {
                  if (type === 'display') {
                      var badgeColor = '';
                      switch (data) {
                          case 'Waiting For Receiving Committee':
                              badgeColor = 'red';
                              break;
                          case 'In Front Office For 24 Hours':
                              badgeColor = 'orange';
                              break;
                          case 'Moving To Security Storage':
                              badgeColor = 'blue';
                              break;
                          case 'Moving To Housekeeping Storage':
                              badgeColor = 'grey';
                              break;
                          case 'In Security Storage':
                              badgeColor = 'green';
                              break;
                          case 'In HouseKeeping Storage':
                              badgeColor = 'Fuchsia';
                              break;
                          case 'Delivery Request':
                              badgeColor = 'Sienna';
                              break;
                          case 'Moving To Front Office':
                              badgeColor = 'Turquoise';
                              break;
                          case 'Item Has Been delivered to Its Owner':
                              badgeColor = 'black';
                              break;
                      }
                      return '<span class="badge" style="background-color: ' + badgeColor + ';">' + data + '</span>';
                  }
                  return data;
              }
          },
      ],
      createdRow: function (row, data, dataIndex) {
          var stageName = $('td:eq(5)', row).text();
          var checkboxChecked = $('td:eq(8) input[type="checkbox"]', row).prop('checked');

          if ((stageName === 'Moving To Security Storage' || stageName === 'In Security Storage' || stageName === 'Delivery Request') && checkboxChecked) {
              $(row).show();
          } else {
              $(row).hide();
          }
      }
  });

});

i also tried this option

extend: 'print',
exportOptions: {
columns: ':visible:not(.no-print)'

also not effective , any idea how to do that ???

Type Error: Cannot read properties of undefined (reading 'sClass')

$
0
0

Link to test case: Website is behind auth

Debugger code (debug.datatables.net): okahog

Error messages shown:

Uncaught TypeError: Cannot read properties of undefined (reading 'sClass')
at oe (datatables.min.js:16:14190)
at Ce (datatables.min.js:16:29154)
at ye (datatables.min.js:16:22504)
at Oe (datatables.min.js:16:33344)
at O (datatables.min.js:16:6955)
at HTMLTableElement.<anonymous> (datatables.min.js:16:7142)
at Function.each (jquery-3.7.0.min.js:2:3129)
at ce.fn.init.each (jquery-3.7.0.min.js:2:1594)
at ce.fn.init.$ [as dataTable] (datatables.min.js:16:1300)
at B.fn.DataTable (datatables.min.js:16:91021)

Description of problem:

I upgraded to Databtables 2.03, which includes all my dependencies from DT 1.

My config:

// DataTables
document.addEventListener("DOMContentLoaded", function () {
  DataTable.moment("DD-MM-YYYY");

  const table = new DataTable("#coinTable", {
    responsive: true,
    searching: true,
    ordering: true,
    paging: true,
    buttons: ["copy", "excel", "pdf"],
    order: [[1, "asc"]],
    columnDefs: [
      {
        targets: "no-sort",
        orderable: false,
      },
    ],
    lengthMenu: [
      [25, 50, 75, -1],
      [25, 50, 75, "All"],
    ],
  });
});

Custom CSS and BS5 conflict after upgrading to DT v2.0

$
0
0

I have been using v1.13.11 with custom BS5 templates provided by Themesbrand (https://themesbrand.com/velzon/html/default/tables-datatables.html) in ASP Net Core Razor pages.

After upgraded to v2.0, I noticed the following:

  1. A border box was shown when mouse cursor was over a column header.
  2. Extra top and bottom border lines were shown.

I have the following in my codes:

<link href="https://cdn.datatables.net/v/bs5/dt-2.0.5/r-3.0.2/rg-1.5.0/datatables.min.css" rel="stylesheet" type="text/css">

<script src="https://cdn.datatables.net/v/bs5/dt-2.0.5/r-3.0.2/rg-1.5.0/datatables.min.js"></script>

I have tried to modify the custom CSS but I couldn't identity the correct class/attribute to change. Any advice on how to rectify the issues? Please help. Thanks.

DT debugger bookmarklet "Version check" not working

$
0
0

My DT debugger bookmarklet "Version check" just shows "Loading...". I'm on DT 2.0.5.

default value for a field into custom form

$
0
0

Hi,
i need to know how to set a dafault value for a custom form field, in detail i need to insert the current datetime for a datetime field. Thks in advance


Fixed columns not working with paging

Header export issue

$
0
0

I'm using the following code in datatable with server side set to true
var buttonCommon = {
exportOptions: {
format: {
header: function ( text, index, node ) {
// Change column header if it includes something
return text.includes("something") ?
text.replace( 'something', 'some other thing' ) :
text;
}
}
}
};
but in the excel It's not replacing it's actually only increasing the width of the column.

Question on the new "layout" option

$
0
0

Link to test case: none, sorry
Debugger code (debug.datatables.net): none, sorry
Error messages shown: none
Description of problem:

I am using DT with a Bootstrap4 binding.
In DT 1.x it was possible to alter the DOM to avoid the headers and footers are printed by wrapping everying in a div with class d-print-none. I don't see how I can do that with the existing setup. How can I wrap a predefined element like paging or search in a container element?

Thanks in advance for your help :)

Editor Edit all selected rows and submit

$
0
0

hey,

I built a custom button to get all the selected rows and change the value of a column based on another. it works great but I can't get it to submit multiple lines I have multiple selected.

is there a better way to do this or am I just missing something here.

{
        text: "Return",
        editor: editor,
        className: "mb-2 btn btn-small btn-primary",
        enabled: false,
        action: function (e, dt, node, config) {
          let rows = dt_fixedheader.rows(".selected");
          console.log("# of selected=" + rows.data().length); //it shows number of selected row
          if (rows.data().length > 0) {
            rows.every(function (rowIdx, tableLoop, rowLoop) {
              console.log(rowIdx, tableLoop, rowLoop)
              editor.edit(dt_fixedheader.row(rowIdx), false).set("checkedin", editor.get("checkedout")).submit();
          
            });
          }
        },
      }

Pre-defined search returns all rows if one of the criteria is never met

$
0
0

Link to test case: Not available
Debugger code (debug.datatables.net): akeduz
Error messages shown: No error messages
Description of problem: I am using a pre-defined search to allow users to quickly find incomplete records. The problem is that sometimes the category used for one of the components of the search is not met which then results in the entire search to not work (all records are shown). Is it possible to run a pre-processing step prior to running the search to ensure that the category required is present?

My only other option is to create some auxiliary field that is e.g., "N" when the condition is not met and use that auxiliary field with a not equal, but I would prefer to avoid that.

Thank you.

Editor : DOM sourced table

$
0
0

Hi,

Your example "say that Editor will work with any data source that DataTables can use".
https://editor.datatables.net/examples/advanced/htmlTable.html

But how does with work if I want to initialize the table with this ?
data: [["","Genève","Veyrier"],["","Vaud","Morges"]],

Up until now, all my tables were initialized this way, each row being an array of strings.
But with Editor, clicking on a cell raises an error: Unable to automatically determine field from source.

Then I tried to convert the above data, so that each row be an object of keys/values with an id added for good measure:
[{"id":"0","select":"","state":"Genève","city":"Veyrier"},{"id":"1","select":"","state":"Vaud","city":"Morges"}]
But this raises the warning: Requested unknown.

An example of locally provided data (not HTML, just a plain array) would be much appreciated.

inline Editor: is label necessary ?

$
0
0

Hi,

In the "Selected columns only" example, all editing is done inside the cell (no modal) :
https://editor.datatables.net/examples/inline-editing/columns.html

Thus I am wondering what is the use of labels in fields, e.g. label: 'First name:' ?

And in order to use my own REST interface (without the DataTables_Editor_PHP which is overkill for my small table), I hesitate between pointing the Editor's ajax to my own custom PHP endpoint (is there any example that describes the ajax POST messages ?) or use blur event on each cell to call my own custom ajax code.

Which do you suggest is better ?


How long should it take to generate Data Table with 50000 rows and 100 column.

$
0
0

Just running some benchmarks to see if the speed I get is normal due to the large amount of data or something in my code is not correct. So I decided to generate a Data Table with no other processing (render callbacks or cell/row elements processing) involved.

I have used an custom method to generate a data array with **50000 **rows and **100 **columns. It would look something like:

    const DATA_ARRAY = [
        { "Column 1": 9999, "Column 2": 9999, "Column 3": 9999, ....... , "Column 100": 9999 },
        { "Column 1": 9999, "Column 2": 9999, "Column 3": 9999, ....... , "Column 100": 9999 },
    ];

I have a custom method that would auto-generate the "columns" data needed and assigned is to a COLUMNS_DATA constant.

I have added my plain table element <table></table> to the DOM. Since I am using jQuery, I have the jQuery object for table in a $TABLE constant.

I have created a data/object that will contain the "data" and "columns" information:

const SETTINGS_DATA = { 'data': DATA_ARRAY, 'columns': COLUMNS_DATA };

I then ran the Data Tables method to generate the Data Table:

$TABLE.DataTable(SETTINGS_DATA );

From that last call, it took 50 seconds before the table showed up on my page in the Chrome browser. The browser sometimes did the "Aw, Snap" because it ran out of memory.

I did a few more test:

  • With 50 columns, it took 23 seconds.
  • With 25 columns, it took 9 seconds.
  • With 15 columns, it took 5 seconds.
  • With 5 columns, it took 2 seconds.

Maybe it would be better to use the server-side option, but trying to see if the speed I am getting is expected for that amount of data.

How to exclude action column when I download a file from datatable

$
0
0

Link to test case:
Debugger code (debug.datatables.net):
Error messages shown:
Description of problem:

FixedColumns server-side processing error

$
0
0

Link to test case: https://datatables.net/extensions/fixedcolumns/examples/initialisation/server-side-processing.html
Error messages shown:
Uncaught TypeError: Cannot read properties of undefined (reading 'anCells')
at _pluck_order (dataTables.js:1235:23)
at _Api.<anonymous> (dataTables.js:8485:11)
at _Api.iterator (dataTables.js:6757:17)
at _Api.<anonymous> (dataTables.js:8484:15)
at _Api.<anonymous> (dataTables.js:6975:18)
at _Api.nodes (dataTables.js:6847:17)
at FixedColumns._fixColumn (dataTables.fixedColumns.js:301:74)
at _Api.<anonymous> (dataTables.fixedColumns.js:201:26)
at _Api.<anonymous> (dataTables.js:9552:9)
at _Api.iterator (dataTables.js:6757:17)
Description of problem: When click other pages the fixed column not fixed anymore.

Upgrade Datatables from V 1.10.7 to V 1.13.4 issue

$
0
0

After upgrading datatables, Table td width remains same for all columns instead of width based on content.

Can anyone guide me through ?

Responsive + always showing

$
0
0

Hi all,

Struggling with a table at the moment. Whenever i load up the table it always adds the '+' responsive part in the first column, even though all of the columns are showing. Ive spent about 3 days trying to solve this but im struggling. The table is responsive when the screen resizes but from the page load i cannot get the table without the '+' added.

Any obvious things to look at??

Thanks

Table controls not aligned in Child table

Default export options?

$
0
0

CSV export has started including subheading since moving from 1.10.15 to 2.0.5

I was hoping something like:
$.extend($.fn.dataTable.ext.buttons.csvHtml5, {
exportOptions: {
customizeData: function(data) {
data.headerStructure.pop();
}
}
});

Would have worked, but doesn't appear to, is there an expected way of adding universal settings for buttons?


How can I make a checkbox or select box have all the filters name in options present in datatable?

$
0
0

I am using the jQuery Datatables WordPress plugin to display a data table. The Daatables have 230+ search filters. So It takes a lot of screen space and does not look great.

Is there any option in the jQuery data table to have a checkbox selection or select box selection on the front end where a user can choose which filter he/she wants to use? Or Any other suggestions?





Latest Images