Quantcast
Channel: Recent Discussions — DataTables forums
Viewing all 82257 articles
Browse latest View live

SearchBuilder / stateSave: SCRIPT5007: Unable to get property 'topRow' of undefined or null referen

$
0
0

Error messages shown:

SCRIPT5007: Unable to get property 'topRow' of undefined or null reference

Description of problem:

When I enable stateSave an error appears for searchBuilder trying to find a property of topRow?

Has anyone encountered this before?

(u.searchBuilder=b._collapseArray(b.getDetails(!0)))});this.s.dt.on("column-reorder",function(){b.rebuild(b.getDetails())});a&&(a=this.s.dt.state.loaded(),null!==a&&void 0!==a.searchBuilder?(this.s.topGroup.rebuild(a.searchBuilder),this.s.topGroup.dom.container.trigger("dtsb-redrawContents"),this.s.dt.page.info().serverSide||(a.page?this.s.dt.page(a.page).draw("page"):this.s.dt.scroller&&this.s.dt.scroller().scrollToRow(a.scroller.topRow)),this.s.topGroup.setListeners()):!1!==this.c.preDefined&&(this.c.preDefined=


Cannot read property 'sWidth' of undefined - Bug in jQuery Datatables Triggered by ColVis

$
0
0

Hello

I was just posting here to raise awareness of a bug I hit regularly when working with jQuery Datatables where it throws the error "Cannot read property 'sWidth' of undefined" which is difficult to debug as the error provided doesn't indicate what the issue actually is.

It was posted on StackOverflow in 2013 and is still present. If columns are defined in the code but the number of columns defined does not match the table header then this always triggers this error so you must go through until you locate the difference.

The issue is that jQuery Datatables attempts to read the width of a column when that column is hidden triggering the error above. If it has a case statement to check the column is visible before attempting to read the size then the issue does not occur.

Further details of the error are here:
https://stackoverflow.com/questions/20673825/error-with-jquery-datatables-and-colvis-plugin-cannot-read-property-swidth-of

Please could some priority be given to fix this annoying issue?

Thanks
Robin

How do I fix this error : $.fn.dataTable.Editor is not a constructor

$
0
0

I have purchased the Editor license, but the JS in the downloaded installation package cannot be used. The error is as follows:
Uncaught TypeError: $.fn.dataTable.Editor is not a constructor
at HTMLDocument.<anonymous> ((索引):84:22)
at mightThrow (jquery-3.5.1.js:3762:29)
at process (jquery-3.5.1.js:3830:12)

Excel Export

$
0
0

I think Excel is still important in so many ways. Over 50% of my users want to be able to easily export their data to Excel. And they want it in a way that they can work with the data.

If you are not living in America or the UK you know the issue: It is hardly ever possible to work with exported numeric data. Formatted European numeric data get mutilated by Excel in a terrible way. I used the features that Data Tables provides to get it done - somehow.

But then the next problem emerged: How to do it,
a) if the user wants only selected columns (selected with the colvis button), or
b) the user wants wysiwyg: only what is displayed on the screen (not including child-rows hidden by the "responsive" extension)
- and still get the export formatting done in order to prevent Excel from destroying part of the data.

This was hard to develop and my code for this is ugly, I think.

I would strongly encourage a better solution for this. If anyone is interested how I resolved this with my ugly solution I can share it.

Datatables Row Grouping 508 not compliant?

$
0
0

I am using Datatables Rowgrouping for my project and the accessiblity team ran a test on this and said that the table is not 508 complaint. They want the row groups to read as header as well (ex: Edinburg, London etc.). Basically the screen reader should read City name along with Name header and name of the person. Similarly read City name along with Position header and postition descrtiption.

I looked at the code and row groups (city names) are <td> instead of <th>. Is there a way to make them th with "scope" attribute.

Thanks

https://datatables.net/examples/advanced_init/row_grouping.html

Once I add autoWidth: false the table stops being sortable.

$
0
0

I have an already rendered table that I added datatables to, using the basic installation instructions.
The default truncate the table. I tried to 'force' it to stay with typical html 'width' options, but they get overridden.
if I add autoWidth: false or columns, the sorting gets turned off.
** $('#example').DataTable( {
"columns": [
null,
null,
null,
null,
{ "width": "50%" }
]
} );**

If I decide to change one thing, do I have to go and set everything else?

responsive.details.renderer

$
0
0

I would like to apologize before I start: Normally I don't ask other people to write my code but this time I would be very grateful for a code example doing something similar. So please accept my apologies for asking.

I have a very large data table with very many columns. About one trillion of them never sees the sunlight and is always hidden in a child row. What I would like to have is some kind of heading to group the rows (which are actually table columns) inside the child row into categories. For illustration purposes I inserted those yellow lines in the screen shot below. That could be the place for a heading that could be right above a column name and then one or two line breaks or so. Or nicer ...

Those columns before or after a heading could be identified by class also on th or td level; both is easy to accomplish. I didn't find an example that I could follow but I know "responsive.details.renderer" is probably the correct path to follow.

Any suggestions or - even better - sample code? Many thanks in advance.

One-to-many nested datatable in editor

$
0
0

Link to test case:
Debugger code (debug.datatables.net):
Error messages shown:
Description of problem:
Is it possible to have a one-to-many nested editor table? I see how you do it in the example here with a checkbox. But I need to have a nested table.

I have a list of tickets which displays fine and I can edit as normal. But then I also have the list of TicketDetails that need edited. See my model below.

data: [
  {
    "TicketID": 4650,
    "TicketTypeID": 1,
    "StatusID": 1,
    "StatusTitle": "New",
    "SeverityID": 1,
    "SeverityTitle": "High",
    "Subject": "Test 14",
    "DateExpected": "/Date(1648699200000)/",
    "DateCreated": "/Date(1648758398023)/",
    "DateModified": "/Date(1648758398023)/",
    "DateCompleted": null,
    "CreatedBy": "edavis",
    "DepartmentID": 2,
    "DepartmentTitle": "IT",
    "AssignedTo": null,
    "AssignedToDate": null,
    "ResolutionID": null,
    "ResolutionTitle": null,
    "Hours": null,
    "TicketDetails": [
      {
        "Key": 15864,
        "TicketDetailID": 15864,
        "TicketID": 4650,
        "DateCreated": "/Date(1648758398027)/",
        "CreatedBy": "edavis",
        "Details": "Testing 14"
      }
    ]
  }
]

In my editor I have setup my fields as follows

fields: [            
            { name: "TicketID", label: 'ID', type: "readonly"},
            {
                name: "StatusID", label: 'Status',
                type: "select",
                options: [getStatusDropdownEdit()]},
            //{ name: "StatusTitle", label: 'Status' },
            {
                name: "SeverityID", label: 'Severity',
                type: "select",
                options: [getSeverityDropdownEdit()] },
            //{ name: "SeverityTitle", label: 'Severity' },
            { name: "Subject", label: 'Subject' },
            {
                name: "DepartmentID", label: 'Department',
                type: "select",
                options: [getDepartmentDropdownEdit()] },
            //{ name: "DepartmentTitle", label: 'Department' },
            {
                name: "DateCreated", label: 'Date Created', type: "readonly",
                data: function (d) {
                    if (d != null) { return moment(d).format("MM/DD/YYYY HH:mm:ss"); }
                    else { return ''; }
                }
            },
            {
                name: "DateExpected", label: 'Date Expected', type: "datetime",
                data: function (d) {
                    if (d != null) { return moment(d).format("MM/DD/YYYY HH:mm:ss"); }
                    else { return ''; }
                }
            },
            {
                name: "DateModified", label: 'Date Modified', type: "readonly",
                data: function (d) {
                    if (d != null) { return moment(d).format("MM/DD/YYYY HH:mm:ss"); }
                    else { return ''; }
                }, visible: false
            },
            {
                name: "DateCompleted", label: 'Date Completed', type: "readonly",
                data: function (d) {
                    if (d != null) { return moment(d).format("MM/DD/YYYY HH:mm:ss"); }
                    else { return ''; }
                }
            },
            { name: "CreatedBy", label: 'Created By' },
            {
                name: "AssignedTo", label: 'Assigned To',
                type: "select",
                options: [getAssignedToDropdownEdit()] },
            {
                name: "AssignedToDate", label: 'Assigned Date', type: "readonly",
                data: function (d) {
                    if (d != null) { return moment(d).format("MM/DD/YYYY HH:mm:ss"); }
                    else { return ''; }
                }
            },
            {
                name: "ResolutionID", label: 'Resolution',
                type: "select",
                options: [getResolutionDropdownEdit()] },
            //{ name: "ResolutionTitle", label: 'Resolution' },
            { name: "Hours", label: 'Hours' },
            {
                label: 'Ticket Details:',
                name: 'TicketDetails[]',
                type: 'datatable',
                editor: ticketDetailsEditor,
                optionsPair: {
                    value: 'id',
                },
                config: {
                    searching: false,
                    info: false,
                    paging: false,
                    select: false,
                    order: [[0, 'asc']],
                    data: 'TicketDetails[]',
                    columns: [
                        {
                            title: 'ID',
                            data: 'TicketDetailID',
                            type: "readonly",
                        },
                        {
                            title: 'Ticket ID',
                            data: 'TicketID',
                            type: "readonly",
                            visible: false
                        },
                        {
                            title: 'Created By',
                            data: 'CreatedBy',
                            type: "readonly",
                        },
                        {
                            data: "DateCreated", title: 'Created', type: "date",
                            render: function (d) {
                                if (d != null) { return moment(d).format("MM/DD/YYYY HH:mm:ss"); }
                                else { return ''; }
                            }
                        },
                        {
                            title: 'Details',
                            data: 'Details',
                            type: "readonly",
                            orderable: false,
                        }
                    ],
                    buttons: [
                        { extend: "create", className: 'btn-dark', editor: ticketDetailsEditor }
                    ]
                }
            }
        ]

You can see in my TicketDetails field I'm trying to pass the data 'TicketDetails[]' but this doesn't work.

I'm trying to set this up so that the nested table (TicketDetails) basically uses local editing, which would allow changes to be submit when I update the parent editor (Tickets) rather than setting this up to have 2 calls to return my data and 2 calls to submit my changes.

Any suggestions? I've found examples of creating a nested child table in the parent table like an accordion but that's not what I'm trying to do. I'm wanting this all to be done in one editor.

Thanks!


Hide entries in child row

$
0
0

When using the responsive extension with many columns in the child row I wanted to hide empty cells for the respective child row when it is displayed. So this is not about hiding empty columns but about hiding empty fields in child rows individually for each displayed child row.

This works (class "hidden" is a Bootstrap class; you might want to use somehting else).

table.on( 'responsive-display', function ( e, dt, row, show, update ) {
        var x = row.index();
        $('tbody tr.child td.child ul li[data-dt-row="' + x + '"]').each(function(){
            if ( $(this).find('.dtr-data').text() <= "" ) {
                $(this).addClass("hidden");
            } else {
                $(this).removeClass("hidden");
            }
        })
    })

After Table Has Been Filtered, Get Hidden Column Value and Make a Global Variable

$
0
0

Hello,

I have the following filter for my DataTable to only show Items that have a date within the current week.

$.fn.dataTable.ext.search.push( //creating my own filter function for the table
            function(settings, searchData, index, rowData, counter, statusClass) { 
    
                var now = moment(); //creating another now variable which is an instance of the current date
                var monday = now.clone().weekday(1); //creating an instance of the current week Monday Date
                var friday = now.clone().weekday(5); //creating an instance of the current week Friday Date
    
                let mondayF = monday.format('MM/DD/YYYY'); //formatting the monday date to MM/DD/YYYY
                let fridayF = friday.format('MM/DD/YYYY'); //formatting the friday date to MM/DD/YYYY
    
                var sMonday = searchData[2]; //created a var to search through the 3rd column (0 index) which contains all of the Monday Dates
                var sFriday = searchData[10]; //created a var to search through the 11th column (0 index) which contains all of the Friday Dates
    
                // Get Datatables API
                var api = $.fn.dataTable.Api('#myTable');
                if (mondayF == sMonday && fridayF == sFriday) {
                    $('#under_txt').html("Week Of: " + moment(mondayhead).format("MMM Do YYYY")); //applying the monday date of the current week back to the #under_txt after the search is cleared
                    return true;
                }
                // Does row contain the search term? If so it will show searched data outside of the current week and only items within the week of the date searched
                if (searchData.includes(api.search())) {
                    $('#under_txt').html("Week Of: " + moment($('#dpicker').val()).startOf('isoWeek').format("MMM Do YYYY")); //applying the searched date value to the #under_txt
                    return true;
                }
                //if current monday = monday in table, only show that. Same for the friday value
                return false;
            }
        );

This returns the exact values I want to display in the table. I have an external REST call that I am trying to filter by dates, but it doesn't work due to some user's time zone. But the filter works fine for those users, so I have created a hidden column value to pull the list item ID through that is tied to all of the information. Is there a way I can get that column value globally to append to the end of my REST API openDialog()?

Lets say the column is like as below,

{"data" : "ListItemID", visible: false},

and below is what I need to append that filtered ListItemID value to. This open dialog is in the .done() success function of an Ajax call.

openDialog('/sites/Projects/Report/Lists/Report/EditForm.aspx?Id=' + [Insert ListItemID Here])

RowReorder example not clear to me if table.on('row-reorder') is required.

$
0
0

Description of problem:
It is not clear to me if in the Editor RowReorder example, it is required to use table.on('row-reorder'...)?

How Can I open the modal popup to display data of one datatable using Link on another page

$
0
0

I have datatable that I am using to display data for all assets from database. In this table I want to put a link to a field which can open modal popup which can display data from another datatable with selected fields. I check similar questions in forum but mostly all having modal popup for same table where they want to open it. But in my case I want to open modal popup of another table in my page using link.

Please direct me to right direction by providing any working example and reference documents.

Here is my code so far.

Table 1 - where I applied Link to table field called - scadaPoints

    var table = $('#assyntCx_Table').DataTable( {
        dom: 'lBfrtip',

        serverSide: true,
        processing: true,
        ajax: {
          url: "../ajax/at/assets_ss.php",
          type: "POST",
          deferRender: true,

        },

        //TABLE WINDOW
        scrollY:        "65vh",
        scrollX:        true,
        scrollCollapse: true,
        paging:         true,
        fixedColumns:   {
          left: 2
        },


            columns: [
          { data: "id" },
          { data: "designTag",    className: "dt-nowrap", },
          { data: "specTag",      className: "dt-nowrap", },
          { data: "loc",          className: "dt-nowrap", },
          { data: "building",     className: "dt-nowrap", },
          { data: "room",         className: "dt-nowrap editable", },
          { data: "level",        className: "dt-nowrap editable", editField: "A.levels", },
          { data: "assetType",    className: "dt-nowrap editable", editField: "A.assetType",},
          { data: "entity",       className: "dt-nowrap editable", editField: "A.entity",},
          { data: "design",       className: "dt-nowrap editable", },
          { data: "assetStatus",  className: "dt-nowrap editable", editField: "A.assetStatus", },
          { data: "oldID",        className: "dt-nowrap editable", },
          { data: "PR",           className: "dt-nowrap", },
          { data: "SR",           className: "dt-nowrap", },
          { data: "subsystem",    className: "dt-nowrap", },
          { data: "discipline",   className: "dt-nowrap", },
          { data: "PICO",         className: "dt-nowrap", },
          { data: "SAT",          className: "dt-nowrap", },

          // This is the field where I want to apply Link to open Modal popup

          { data: "scadaPoints",          
            className: "dt-nowrap dt-center", 
            render: function ( data, type, row) {
                if ( type === 'display' || type === 'filter' ) {
                if(data != "0"){
                    return '<a href="#" data-toggle="modal" data-target="#scadaModal">'+data+'</a>';

                   // I tried to made button instead link to try below code but its not working
                    //return '<button class="btn btn-primary" data-toggle="modal" data-loopNo="'+row.loopNo+'" data-scadatag="'+row.scadatag+'" data-target="#scadaModal">'+data+'</button>'
                }else{
                    return '';
                }
                //../asset/scadapoints.php?assetID='+row.id+'
            }
            if(data != "0"){
                return data;
            }
            else{
                return '';
            }

            },
        },
          { data: "U.username",   className: "dt-nowrap editable", editField: "A.bic",},
          { data: "assetPhase",   className: "dt-nowrap editable", editField: "A.phase",},
          { data: "seq",          className: "dt-nowrap editable", },
          { data: "comment",      className: "editable", },
            ],

Table 2 - the data of this table I want to display on modal popup. on this table I made modal and try out some code which is not working.

    <div class="container-fluid ms-7 w-auto">
      <div class="card">
        <div class="card-body">
          <div id='phaseTable' class='content'>
            <table id='assyntCx_Table' class='stripe row-border order-column' style="width:100%">
              <thead>
                <tr>
                  <th data-priority="10" class='text-center'>Loop Number</th>
                  <th data-priority="10" class='text-center'>SCADA Tag</th>
                  <th data-priority="20" class='text-center'>Location</th>
                   <th data-priority="20" class='text-center'>Equipment Tag</th>
                   <th data-priority="20" class='text-center'>Asset Type</th>  
                   <th data-priority="20" class='text-center'>Subsystem</th> 
                   <th data-priority="20" class='text-center'>Level</th> 
                   <th data-priority="20" class='text-center'>Room</th> 
                   <th data-priority="20" class='text-center'>Service Description</th>
                  <th data-priority="30" class='text-center'>PLC ID</th>
                  <th data-priority="30" class='text-center'>Cabinet Tag</th>
                  <th data-priority="30" class='text-center'>Field End Terminated</th>
                  <th data-priority="30" class='text-center'>Marshalling Panel Terminated</th>
                  <th data-priority="30" class='text-center'>Comments</th>
                </tr>
              </thead>

            </table>
          </div>
        </div>
      </div>
    </div> 

    <!-- Scada Model Popup -->
    <div id="scadaModal" class="modal fade" tabindex="-1" role="dialog" aria-hidden="true">
    <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <h3 id="modalTitle">Scada Points Details</h3>
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                </div>
                <div class="modal-body"></div>
                <div class="modal-footer">
                    <button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
                </div>
            </div>
        </div>
    </div> 


    $(document).ready(function() {

    var table = $('#assyntCx_Table').DataTable( {
        dom: 'lBfrtip',
        ajax: {
          url: "../ajax/at/scadapoints.php",
          type: "POST",
          deferRender: true,

        },

        //TABLE WINDOW
        scrollY:        "65vh",
        scrollX:        true,
        scrollCollapse: true,
        paging:         true,
        fixedColumns:   {
          left: 2
        },


            columns: [
          { data: "A.loopNo",    className: "dt-nowrap", },
          { data: "A.scadaTag",          className: "dt-nowrap", },
          { data: "LocationName",          className: "dt-nowrap", },
          { data: "T.assetTag",          className: "dt-nowrap", },
          { data: "assetTypeName",          className: "dt-nowrap", },
          { data: "systemName",          className: "dt-nowrap", },
          { data: "levelTLA",     className: "dt-center", },
          { data: "Room",    className: "dt-center", },
          { data: "status",         className: "dt-nowrap", },
          { data: "A.plcID",    className: "dt-nowrap"},
          { data: "A.cabinetTag",       className: "dt-nowrap"},
          { data: "FTerminated",      className: "dt-center"  },
          { data: "MPTerminated",      className: "dt-center"},
          { data: "A.comments",      className: "dt-nowrap", },
            ],

        //SHOW SELECTION & SAVE PREVIOUS STATE
        select: true,
        stateSave: false,

        //DISABLE AUTOWIDTH
        "autoWidth" : false,

        //BUTTONS
        buttons: [],

        //PAGINATION OPTIONS
        pageLength: 250,
        lengthMenu: [[50, 100, 250, 500, -1], [50, 100, 250, 500, "All"]],

        initComplete: function() {
          var api = this.api();

          // Apply the search
          api.columns().every(function() {
            var that = this;

            $('input', this.footer()).on('keyup change', function() {
              if (that.search() !== this.value) {
                that
                  .search(this.value)
                  .draw();
              }
            });
          });
        }
      } );

    //   SCADA MODEL

      $("#scadaModal").on('show.bs.modal', function (e) {

         var triggerLink = $(e.relatedTarget);
         var loopNo = triggerLink.data("A.loopNo");
         var scadatag = tiggerLink.data("A.scadaTag");

         $("#modalTitle").text(title);
         $(this).find(".modal-body").html("<td>Loop No: "+loopNo+"</td><td>Scada Tag: "+scadatag+"</td>");
       });



    });

Print Not working working in Electron js app

$
0
0

Only white popup window showing while press print button from data table in Electron Application.
screen short attached for your reference.

Not showing other button like, pdf / csv / excel button

i am new in data table. can any body help me to find solution

My script as given below

var $  = require( 'jquery' );
var dt = require( 'datatables.net' )();
require( 'datatables.net-buttons/js/buttons.colVis.js' )(); //# Column visibility
require( 'datatables.net-buttons/js/buttons.html5.js' )();  //# HTML 5 file export
require( 'datatables.net-buttons/js/buttons.print.js' )();  //# Print view butto

$(document).ready( function () {
        
            var table = $('#table_id').DataTable({
              "dom": '<"toolbar">Bfrtip',
              "language": {
                "paginate": {
                  "next": "Next"
                }
               
                
              },
               buttons: [
                'copy', 'csv', 'excel', 'pdf', 'print'
            
        ]
    
            })

            $("div.toolbar").html('<input class="datePicker" type="month" name="" id="dated">');
          dated.onchange = evt =>{
            table.draw();
            
          }
            $.fn.dataTable.ext.search.push(
              function(settings, data, dataIndex) {
                var sdate =  $('#dated').val().split('-')
                var month = sdate[1]
                var year = sdate[0]
              console.log(data)
                var date = data[1].split('-');
                if ((isNaN(year) && isNaN(month)) ||
                  (isNaN(month) && year == date[0]) ||
                  (date[1] == month && isNaN(year)) ||
                  (date[1] == month && year == date[0])
                ) {
                  return true;
                }
                return false;
              }
            );
          });

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

datatables in a modal: did not show in table format

$
0
0

Please, how to fix it?

Bootstrap 5

<!-- Modal -->
<div class="modal fade" id="stdEnrollsModal" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
  <div class="modal-dialog modal-dialog-scrollable modal-lg">
    <div class="modal-content">
      <div class="modal-header">
        <h5 class="modal-title" id="exampleModalLabel">Matriculas do aluno</h5>
      </div>
        <table id="teste" class="display nowrap" style="width:100%"></table>
      <div class="modal-footer">
        <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Fechar</button>
        <!-- <button type="button" class="btn btn-primary">Save changes</button> -->
      </div>
    </div>
  </div>
</div>



<script>
function showStdEnrolls(dataArray){
  // 'show': show modal
  $('#stdEnrollsModal').modal('show');
  // table: to check on click - new version
  let table = $('#teste').DataTable({
    data: dataArray,
    
    // TABLE HEADINGS BELOW
    columns: [
      {"title":"Id"},
      {"title":"Col-1"},
      {"title":"Col-2"},
      {"title":"Col-3"},
      {"title":"Col-4"},
      {"title":"Col-5"},
      {"title":"Col-6"},
      {"title":"Col-7"},
      {"title":"Col-8"},
      {"title":"Col-9"},
      {"title":"Col-10"},
      {"title":"Col-11"},
      {"title":"Col-12"},
    ],    
    responsive: true,    
    retrieve: true,
    "language": {
      "url": "https://cdn.datatables.net/plug-ins/1.11.5/i18n/pt-BR.json"
    },
  })
  
  $('#teste').html(dataArray)
}
</script>

Need help with multi select checkbox filter

$
0
0

I need help with multiselect checkbox filter on datatables along with making it responsive. I searched the datatables documentation but did not find anything related to it. I am not a big fan of Search Pane and would like to use checkboxes in the dropdown instead. I have this code but need help with the following: Thanks.

1) I would like to add the text "Select" on top of all fields for the dropdown filter
2) How can I make the table responsive with scrollbar.

Please see the code below:

http://live.datatables.net/xedexixi/1/edit


Ajax DataTable Showing No Data

$
0
0

I have some rows of data, which I'm trying to show in a DataTable. It's an array of objects, but no data is being shown. What am I doing wrong?

jQuery

$( '#csv-datatable').DataTable( { ajax:{ url: '/json.php', dataSrc:'' }, scrollX: true, pagingType: 'full_numbers', drawCallback: function() {
    $( '.dataTables_paginate > .pagination' ).addClass( 'pagination-rounded' );
} } );

Sample JSON

{
   "data": [
      {
         "id": "0",
         "permit": "20221237",
         "status": "invalid"
      },
      {
         "id": "1",
         "permit": "20221292",
         "status": "valid"
      },
      {
         "id": "2",
         "permit": "20221232",
         "status": "valid"
      }
   ]
}

Result

enter image description here

¿Cómo hacer uso de render en datatable?

$
0
0

Estoy teniendo dudas respecto a como utilizar render en data table. Tengo una columna de estatus, lo cual en la base de datos se guarda como valor 1,2 y 3 lo que quiero que me muestre en mi columna estatus es que si el valor es igual a 1 muestre pendiente, 2 En proceso, y 3 terminado. Pero no logro como implementar el case. Espero puedan orientarme.

tablaReportes = $('#tablaReportes').DataTable({
"ajax":{
"url": "bd/reportes.php",
"method": 'POST',
"data":{opcion:opcion},
"dataSrc": ""
},
"columns":[
{"data": "id"},
{"data": "folio"},
{"data": "nombre"},
{"data": "apellido"},
{"data": "direccion"},
{"data": "descripcion_domicilio"},
{"data": "telefono"},
{"data": "num_contrato"},
{"data": "fecha_inicio"},
{"data": "fecha_final"},
{"data": "cuadrilla"},
{"data": "estatus",
"render": function(data){
var status_name = '';
switch(data)
{

              case 1: status_name = 'Pendiente'; break;
              case 2: status_name = 'En proceso'; break;
              case 3: status_name = 'Terminado'; break;
              default : status_name = 'Desconocido'; break;
            }
            return status_name;

          }
        },
        {"data": "observaciones"},
        {"data": "encargado_cuadrilla"},
        {"defaultContent": "<div class='text-center'><div class='btn-group'><button class='btn btn-primary btnEditar'>Editar</button><button class='btn btn-danger btnBorrar'>Borrar</button></div></div>"}

    ]

Lo que quisiera realizar, es algo como esto:
<td>
<?php
switch ($dat['estado']) {
case 1:
$dat['estado'] == '1';
echo '<span class="badge badge-danger">Pendiente</span>';
break;
case 2:
$dat['estado'] == '2';
echo '<span class="badge badge-warning">En proceso</span>';
break;
case 3:
$dat['estado'] == '3';
echo '<span class="badge badge-success">Terminado</span>';
break;
}
?>
</td>

incorrect sorting of Polish characters ąć, etc.

$
0
0

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

incorrect sorting of Polish characters ąć, etc.

$
0
0

incorrect sorting of Polish characters ąć, etc.

SearchPanes 2.0.0 cannot set select to 'multi' inside pane.

$
0
0

the js and css version I use:

  <link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.11.5/css/jquery.dataTables.min.css"/>
    <link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/searchpanes/2.0.0/css/searchPanes.dataTables.min.css"/>
    <link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/select/1.3.4/css/select.dataTables.min.css"/>
    <link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/buttons/2.2.2/css/buttons.dataTables.min.css"/>
    <script src="https://cdn.jsdelivr.net/npm/jquery@3.5.1/dist/jquery.min.js"></script>
    <script type="text/javascript" src="https://cdn.datatables.net/1.11.5/js/jquery.dataTables.min.js"></script>
    <script type="text/javascript" src="https://cdn.datatables.net/searchpanes/2.0.0/js/dataTables.searchPanes.min.js"> </script>
    <script type="text/javascript" src="https://cdn.datatables.net/select/1.3.4/js/dataTables.select.js"></script>
    <script type="text/javascript" src="https://cdn.datatables.net/buttons/2.2.2/js/dataTables.buttons.min.js"></script>

The table settings I use:

var table = $('#example').DataTable({
    searchPanes: {
            layout: 'columns-3',
            cascadePanes: true,
            columns: [2],
            viewTotal: false,
            initCollapsed: true,
            clear: false,
            emptyMessage: "</i></b>EMPTY</b></i>",
            preSelect: [{
                column: 2,
                rows: ['Edinburgh','London']
            }],
            dtOpts:{
                searching: false,
                select:{
                    style: 'multi'
                }
            }
        },
    dom: 'Plfrtip',
});

Finally the select inside SearchPanes is still single not multi.

Viewing all 82257 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>