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

Call search manually

$
0
0

hi

I have a datatable with a custom tool bar who include checkbox

var samplesTestTable = $('#samplesTestsTable').DataTable({
    dom: '<"samples-toolbars">frtip',
    language: {
        "url": urlI18n
    },
    'bLengthChange': false, //hide 'show entries dropdown
    'processing': true,
    'serverSide': true,
    'pagingType': 'simple_numbers',
    'ajax': {
        'type': 'get',
        'url': url,
        'data': function (d) {

            var current = $('#samplesTestsTable').DataTable();
            d.testTypeValue = "[(${testTypeValue})]";
            d.page = (current != undefined) ? current.page.info().page : 0;
            d.size = (current != undefined) ? current.page.info().length : 5;
            d.sort = d.columns[d.order[0].column].data + ',' + d.order[0].dir;
            d.search = d.search.value;
            d.testDoneInclude = $("#testDoneInclude").prop("checked");
        }
    },
    'fnDrawCallback': function (oSettings) {
        $('.dataTables_filter').each(function () {
            $("div.samples-toolbars").html('<div><input type="checkbox" id="testDoneInclude" name="testDoneInclude" class="form-check-input" /><label for="testDoneInclude" class="form-check-label">Test done include</label></div>');
        });
    },
    'columns': [{
            'data': 'id'
        },
        {
            'data': 'buildDate'
        },
        {
            'data': 'productTypesName'
        },
        {
            'data': 'productsName'
        },
        {
            'data': 'supplierName'
        },
        {
            'data': 'machineName'
        },
        {
            'data': 'tests',
            'render': function (data, type, meta) {
                var value = '';
                //loop to get rendered
                for (i = 0; i < data.length; i++) {
                    if (value != '') {
                        value = value + '<br>' + data[i];
                    } else {
                        value = data[i];
                    }
                }

                return value;
            }
        }
    ],
    rowCallback: function (row, data) {
        if (data.nonCompliant) {
            $(row).addClass('nonCompliant');
        }
    }
});

When checkbox value change, I would like to trigger search

$("#testDoneInclude").on('change', function () {
    //call search here
});

How to I will do inLine editing in our datatables plugin

$
0
0

How I will do inline edit in datatables plugin. And how will my user and client column show pop down when I will edit or add this.
Please help me, thanks in advance. :)

How do I create a from click inside another table.

$
0
0

Sorry the description might not make sense but couldn't think of anything else that did.
My problem is:
I have a dataTable. using server-side processing. The table fills fine.
The first column has a couple of possible links:
Clicking on the play works fine. Its the <li> which where the problem begins.

 data = "<button class='btn btn-info btn-sm'><li class='fas fa-play-circle 2x'  id='play'>Play </li><li class='fas fa-thumbtack'></li></button><li class='fas fa-plus' data-id="+row[10]+" ></li>";

I have a div on the page where I want to display the table

           <div id="AD">
                 <table id="ADtable" class="display"></table>
                 <button class="btn btn-sm btn-default" onclick='$("#AD").hide()' >Close</button>
                </div>

in my $(document).ready(function () { I have the following:

 $("#calltable tbody").on( 'click', 'li', function () {
   var data = mytable.row( $(this).parents('tr') ).data();
   var callpath = data[15];
   url = "includes/getattachedData.php";
   data = "callpath="+callpath;
   $.ajax({
      url : url,
      data : data,
      type :"POST",
      success : function(AD){
      console.log("Attached Data "+JSON.parse(AD));
      var returnedJson = JSON.parse(AD);
      $("#AD").show();
// AD is a div on the page which is hidden on load.
    var ADTable =   $('#ADtable').DataTable( { 
           "scrollY": "600",
           "scrollX": true,
                  data: JSON.parse(AD),
                  columns: [
                      { title: "Occurred At" },
                      { title: "Event" },
                      { title: "Key" },
                      { title: "Value" } 
                  ]
               } );
         }
   });
 });

I want this AD table to populate and display.
I've tried using a modal, which was my preferred method and will probably be implemented again once i solve this issue.
I get an error saying cant re-initialize the table. which makes perfect sense because its in the document.ready.
I tried using ADTable.destroy()
I've even tried

 $("#calltable tbody").on( 'click', 'li', function () {
   var data = mytable.row( $(this).parents('tr') ).data();
   var callpath = data[15];
   url = "includes/getattachedData.php";
   data = "callpath="+callpath;
   $.ajax({
      url : url,
      data : data,
      type :"POST",
      success : function(AD){
      var returnedJson = JSON.parse(AD);
      $("#AD").show();
// *** build a temp table ... then destroy it. Then create new table with new data.
      ADTable =   $('#ADtable').DataTable( { 
           "scrollY": "600",
           "scrollX": true
          } );
      ADTable.destroy();
      ADTable =   $('#ADtable').DataTable( { 
           "scrollY": "600",
           "scrollX": true,
                  data: JSON.parse(AD),
                  columns: [
                      { title: "Occurred At" },
                      { title: "Event" },
                      { title: "Key" },
                      { title: "Value" } 
                  ]
                
              } );
   

      }
   });
 });

thinking that if the table already exists it would be destroyed and then created.
I'm going round in circles and getting nowhere..
I think i'm missing something really fundamental but i'm getting a mental block at the moment.
as always... any help is greatly appreciated.

How can i display value of object array with DataTable

$
0
0

Hi,

I'm having this problem, I'm trying to display those values with DataTable. But I got this error message.

'DataTables warning: table id=tbl_method - Requested unknown parameter 'Cleasning' for row 0, column 0.'

Hope someone can advise me where is my mistake. Thank you

--- Here is my sample json data:
[
{
"report_root_cause_cause_id":"1",
"cause_desc":"Cleasning",
"cause_category":"method"
},
{
"report_root_cause_cause_id":"2",
"cause_desc":"Bone",
"cause_category":"material"
}
]

--- Here is my js code:

how to set editor-field required attribute and html5 support(types such as email,tel,num)

$
0
0

some one give me examples,
appreciate!

colReorder compatibility issue other functions

$
0
0

Hi,
I'm trying to implement the colReorder function along with order and colVis functions.

Problem is that if I move a column, the indexes returned from order or colvis functions is the original one and not the actual one.

For example, consider a table with 3 columns (id 0, 1 and 2), column 0 contains internal data so it's hidden by default and not considered in the colVis columns, I order column 2 and then switch it with column 1:
- before moving column, table.settings().order() returns [ 2, "asc" ]
- after column has been moved i expect to receive [ 1, "asc" ], but I get [ 0, "asc" ]

So, if I save table.settings().order()'s result to the database and then use it back on next table initialization, everything is messed up. I've menaged to solve this replacing the returned index with table.colReorder.transpose(idx) in a for cycle, but is this really the way to go?

With colVis is even worst and I don't even know how to work around it. In the same scenario as above, if I select from the dropdown menù the column number 2, it remains visible, column 0 becomes visible between column 2 and 1, column 1 remains visible.
I've set up a demo for you: https://jsfiddle.net/0yc8sd1z/. Please, switch the 2 columns and then try to hide the column "Office".

An error mesg when displaying more columns than there are in table [with FIX]

$
0
0

Hello.
I've created a little fix, but stumbled upon that there's no source code on github and I have to put a fix here.
So here it goes:

<table id="ordersTable>
<thead>
<tr>
<th>id</th> <th>requestDate</th>
</tr>
</thead>
</table>

using Ajax with a response with an array of Objects that have more fields and all those fields are setup in request:

$('#ordersTable').DataTable(
    {
        "ajax" : {
            "url": '/api/clients',
            "dataSrc": ''
        },
        columns: [
            { data: 'id' },
            { data: 'requestDate' },
            { data: 'clientId' }
               ]
     });

suddenly we have an error in browser console:

jquery.dataTables.js:5604 Uncaught TypeError: Cannot read property 'style' of undefined

this is because it has 3 visibleColumns but there are 2 headerColumns. So my fix is to be put on line 5597:

            if (headerCells.length < visibleColumns.length) {
                _fnLog( oSettings, 0, 'Declared visible columns [' + visibleColumns.length + '] > displayed table header cells [' + headerCells.length + ']');
            }

Datatables is not diplayed half of the times.

$
0
0

Hello, I want to use datatables with Drupal 8 but I dont want to do it with the module Datatables because I have limited actions on tables. So, on every html document(through html template) I placed the CDN script and in libraries folder i placed corectly all the files. In my .js file I copy/paste the code that initializes the datatable and everything was looking good.
But, I observed that:

  1. When I refreshing the page half of the times the array will be rendered as Datatables and the other half will be rendered as simple html.
  2. If I visit the page as anonymous user 99% the table is render as Datatable.

I also dowload the files and use them locally from the server but i got the same result.
I know that here is not a discussion about Drupal but I want to know if you ever have a similar situation.


Multibyte strlen for Editor

$
0
0

Dear all,

In Editor last version, in Editor/Validate.php, the functions minLen and maxLen use strlen instead of a multibyte version of strlen, thus if using UTF8 the letter with accents count for 2, and validation fails.

Regards,

Gilles Boussin

How to use server side to retrieve all rows and have datatables not go to server for more

$
0
0

I have a very small data set of about 30 rows but it is very slow to generate the data for these rows. Therefore I am using server side to get the data so the front end shows "processing" to the client until the data is ready. This works well.

However, I am retrieving all the data at once and would like the table to be paginated showing only the first 10 rows. What happens now is that if you press next it tries to retrieve more data from the server side.

Is it possible to retrieve all data at once and have pagination applied and then turn off any further retrieval from the server?

I'm not sure if that makes sense but please ask if not!

Thanks

How do I get dataTables.filter.html.js

$
0
0

I am just preparing a Demo and need dataTables.filter.html.js
how do I get it just for a demo.
if the client decide to use filtering, will pay for it

Individual Search Columns not working in Fixed Columns

$
0
0

I have a table and applied a Fixed column on it fixing the first two columns which was successful on my end. In Addition to this, I also applied individual search columns but it seems to work only on the not fixed columns. It does not work on the fixed columns. If you need to see how I copied and reconstructed the JS here's the code.

$(document).ready(function() { $('#example tfoot th').each( function () { var title = $('#example thead th').eq( $(this).index() ).text(); $(this).html( '' ); } ); var table = $('#example').DataTable({ setTimeout: "50", scrollY: "350px", scrollX: true, scrollCollapse: true, paging: false, heightMatch: "auto", columnFilter: true, fixedColumns: { leftColumns: 2 }, }); table.columns().every( function () { var that = this; $( 'input', this.footer() ).on( 'keyup change', function () { that .search( this.value ) .draw(); } ); } ); });

<style type="text/css">
/* Ensure that the demo table scrolls */
th, td { white-space: nowrap; }
div.dataTables_wrapper {
width: 1210px;
margin: 0 0 0 0;
}
</style>

Note: To explain it more clear, I have let's say 6 columns and the first two columns (columns 1,2) are freezed/fixed. The indivudual column search works on 3,4,5,6 but not it 1 and 2.

Datatable child buttons not worked

$
0
0

hi i used 1.10.12 version, i've created a datatable master and on doble click row i draw a datatable details. on detail i want use a buttons plugin but not worked and not fire anything javascript function. below my code of detail datatable .

function format(rowData) {
var div = $('

')
.addClass('loading')
.css('overflow', 'auto')
.css('height', '40vh')
.text('Loading...');

        var _url = App.getGlobalWcfErgonPath() + "GetDtPianoDiCaricoDetail"
        var _data = JSON.stringify({ pCdDeposito: $("#pCdDeposito").val(), pDtConsegna: moment($('#pDtConsegna').closest('div.date-picker').datepicker('getDate')).format(), pCdGiro: rowData.CdGiro });

        var detailsTableOpt = $('#tablePianodicaricoDetail').clone().attr('id', 'tablePianodicaricoDetail' + rowData.CdGiro).dataTable({
            'dom': 'Bfrtip',
            'data': [],
            'searching': false,
            'info': false,
            'paging': false,
            'language': { "url": "//cdn.datatables.net/plug-ins/1.10.16/i18n/Italian.json" },
            'destroy': true,
            'order': [],
            'buttons': [
                {
                    text: '<i class="fa fa-print" aria-hidden="true"></i>',
                    titleAttr: 'Stampa',
                    action: function (e, dt, node, config) {
                        alert('Button is enabled');
                    }
                },
                {
                    extend: 'copyHtml5',
                    text: '<i class="fa fa-files-o"></i>',
                    titleAttr: 'Copia',
                },
                {
                    extend: 'excelHtml5',
                    text: '<i class="fa fa-file-excel-o"></i>',
                    titleAttr: 'Excel',
                },
                {
                    extend: 'pdfHtml5',
                    text: '<i class="fa fa-file-pdf-o"></i>',
                    titleAttr: 'PDF',
                }
            ],
            'columns': [
                { data: "CdCli", title: "Cliente", className: "dt-center", visible: true, orderable: false },
                { data: "RagioneSociale", title: "Ragione Sociale", className: "dt-left progress", visible: true, orderable: false },
                { data: "GV", title: "GV", className: "dt-right", visible: true, orderable: false, render: function (data, type, full) { return jsFunctionHideZero(data, type, full); } },
                { data: "OF", title: "OF", className: "dt-right", visible: true, orderable: false, render: function (data, type, full) { return jsFunctionHideZero(data, type, full); } },
                { data: "SG", title: "SG", className: "dt-right", visible: true, orderable: false, render: function (data, type, full) { return jsFunctionHideZero(data, type, full); } },
                { data: "PF", title: "PF", className: "dt-right", visible: true, orderable: false, render: function (data, type, full) { return jsFunctionHideZero(data, type, full); } },
                { data: "CR", title: "CR", className: "dt-right", visible: true, orderable: false, render: function (data, type, full) { return jsFunctionHideZero(data, type, full); } },
                { data: "SL", title: "SL", className: "dt-right", visible: true, orderable: false, render: function (data, type, full) { return jsFunctionHideZero(data, type, full); } },
                { data: "TotaleKg", title: "Tot. KG.", className: "dt-right", visible: true, orderable: false },
                { data: "Im", title: "Importo", className: "dt-right", visible: true, orderable: false },
            ],
        });

        $.ajax({
            type: "POST",
            data: { "StringSearch": _data },
            url: _url,
            contentType: "application/json; charset=utf-8",
            dataType: "jsonp",
        }).done(function (result) {
            detailsTableOpt.show();
            detailsTableOpt.DataTable().clear().draw();
            detailsTableOpt.DataTable().rows.add($.parseJSON(result.Data)).draw();
            var h = $(detailsTableOpt.DataTable().table().container()).html()
            div.html(h).removeClass('loading');
        }).fail(function (jqXHR, textStatus, errorThrown) {
            alert("errore:" + textStatus);
        });

        return div;
    }

    function Details(data, tr) {

        var row = $('#tablePianodicaricoMaster').DataTable().row()

        if (tr.child.isShown()) {
            // This row is already open - close it
            tr.child.hide();
            $(tr).removeClass('shown');
        }
        else {
            // Open this row
            row.child(format(row.data())).show;

            $(tr).addClass('shown');
        }

    }

somebody can help me?

More checkbox editor examples for trial evaluation purposes

$
0
0

I started evaluating editor for a small requirement I have but I am not so sure it can be done without changing the underlying data structure

This example https://editor.datatables.net/examples/advanced/joinArray.html is closest to what I am looking for

User selects the row, clicks edit and can checkbox up to 3 options Email, SMS, Call
What is displayed however is based on the enabled field in the JSON

DataTables table is able to render the column correctly with simple { data: "notification.enabled" }
The editor however will not render the checkboxes with the editor fields initialization options below.

Any ideas if this is supported in datatables editor ?

        {
          label: "Notification:",
          name: "notification.options",
          type: "checkbox"
        },

//Data source

[
{
"notification": {
"enabled": ["Email"],
"options": ["Email", "SMS", "Call"]
},
"_id": "5c2bab964d83ef7b06599621",
"name": "Doyle Gerlach IV"

}, {
"notification": {
"enabled": ["Email"],
"options": ["Email", "SMS", "Call"]
},
"_id": "5c2bab964d83ef7b06599620",
"name": "Keagan Batz"
}
]

How to control editor window width with jqueryui / editor template

$
0
0

Hi Allan,

I am using jqueryui, and have a complex form I want to use an editor template with. Following the instructions at https://editor.datatables.net/manual/templates I created a template, but quickly realized that since I'm not using lightbox the class configuration under Lightbox customisation section wouldn't work.

I reverse engineered what you are doing within editor.jqueryui.js, and it looks like the .dialog widget is initialized using Editor.display.jquery.modalOptions which is configured to have width of 600px.

It seems like I cannot override this in my javascript because the dialog is created on initialization. Is there a reason the width needs to be hard-configured? Or is there any way to override this that I'm missing?

BTW, seems to work a little better which changing the 600 to 'auto' using the debugger, but maybe there's something still not quite right with position.


Change titleAttr in language file

$
0
0

hi
i must change language of dataTable in 3 language

i used this code:

            text:       '<i class="fa fa-print"></i>',
            titleAttr:  'Print',
            autoPrint:  true,
            extend:     'print',

And i need change titleAttr in Language file

i used this but cant change

"buttons": {
    "print": {
        "text": "test text",
        "titleAttr": "test titleAttr"
    }
}

please help me

thank you

Nested DataTable and editor within editor window not working

$
0
0

I've been working on a couple of joined tables (recipe / ingredient), and so far I have a table that shows ingredients (editable using inline), and a table that shows recipes (editable with jqueryui editor). The goal is to make the editor jqueryui display a list of ingredients for the selected recipe, and be able to add/edit/delete entries.

What I've done is create a display controller that, in the "open" function, creates dom nodes so the result is a table within my recipe editor jqueryui. This new table is then initialized as it's own DataTable with it's own editor and ajax. Both the child editor and child table both use an ajax modify function so it sends the ID of the recipe in the ajax, so the PHP script can correctly join the recipe and ingredient tables and retrieves only ingredients for the specified recipe (the new DataTable does retrieve and display the correct data).

The problem I'm having is that it whenever I try to save changes to an ingredient amount (by selecting a recipe and editing the amount in the dynamically-created ingredient table), I get a JS error:

Uncaught TypeError: Cannot read property 'canReturnSubmit' of null
    at HTMLDocument.<anonymous> (dataTables.editor.js:21)
    at HTMLDocument.dispatch (jquery.js:5226)
    at HTMLDocument.elemData.handle (jquery.js:4878)

The new values are saved, but the table does not update (until I manually have it reload values from DB) and the jqueryui of the editor does not go away (or if I set it to inline edit, it stays as an editable input, rather than reverting to a table value - same error occurs)

I would prefer not to post the website here, but I have attached the relevant code. If there appears to be anything missing, I'd be happy to provide it.

I have not provided the SQL for the tables or the PHP for the tables, but can if necessary. This looks like a JS problem to me though, so didn't see the need to include.

How can i increase the page size of width in PDF

$
0
0

Need to export PDF report with different sizes (Ex: A2 .....)

Show number of grouped rows per group

$
0
0

Just change line 281 of dataTables.rowGroup.js to
display = this.c.startRender.call( this, dt.rows(rows), groupName + " (" + group.rows.length + ")" , level );

Hide identical cells on consecutive rows

$
0
0

[To move to "Feature requests"?]

Hi everyone,

I have failed finding this (basic?) feature documented anywhere, so I had to write some piece of code instead.

In my table, I wanted to hide the repeated content of similar consecutive rows, like so:
http://jsfiddle.net/bbLjzspf/10232/
It kinda looks like a RowGroup matter, but you can't do it simply with RowGroup.

This is the code I used, plugin-free:

  var myTable;
  var classHidden = "transparent";

  myTable = $('#example').DataTable({
    data: dataSet,
    columns: columnDefs,
    fnRowCallback: function(nRow, aData, iDisplayIndex, iDisplayIndexFull) {
      var bHide = false;
      // _RD Ignore 1st row
      if (iDisplayIndex > 0) {
        // _RD If current data and previously stored data have the same number of cells (should always be the case?)
        if (aData.length == prevData.length) {
          // _RD Compare a given column
          var columnChecked = 0;
          var oldOffice = prevData[columnChecked];
          var newOffice = aData[columnChecked];
          // _RD If the rows match
          if (oldOffice == newOffice) {
            // _RD Tells the row data should be hidden
            bHide = true;
          }
        }
      }
      // _RD Cell(s) to hide or unhide
      var FirstCellToHide = 0;
      var nbOfCellsToHide = 1;
      var cellsToHide = $("td", nRow).slice(FirstCellToHide, nbOfCellsToHide - FirstCellToHide);
      // _RD If the rows should be hidden
      if (bHide) {
        // _RD Hide the cells (Note: "display: none" and "visibility: hidden" don't perform as expected)
        cellsToHide.addClass(classHidden);
      } else {
        // _RD Display the cells back
        cellsToHide.removeClass(classHidden);
      }
      // _RD Save the data from the current row
      prevData = aData;
      // _RD Return the treated row
      return nRow;
    }
  });
<style type="text-css">
    .transparent {
      color: transparent;
    }
</style>

Maybe someone else will have the time to implement this feature?

Various options I can think of:
* N°s of the columns (visible or not) to compare rows from
* N°s of the columns to hide when row has been found similar
* OR: One-line default option : "starting from the left, hide all similar columns over consecutive rows"
* Way to hide the repeated cells: transparent text (default), transparent cell including border, hidden cell, partially lowered opacity ...
* Other styling: remove borders inside a so-called "row group", unify the background color, add separation borders.

Thus, one could easily generate ligthened tables like that one:

Viewing all 81384 articles
Browse latest View live


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