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

DataTables warning: table id=table_name - Invalid JSON response.

$
0
0

Hi all,

since one week I get the following error message in one page what I never changed:
DataTables warning: table id=table_name - Invalid JSON response.

I checked all files and all forum but I don´t find why this error appears.

Today I look at the page resources and I saw that the following error appears in the file table.bookings_dm.php

<br />
<b>Fatal error</b>: Uncaught Error: Call to undefined function number() in /php/Editor/Field.php:593
Stack trace:

0 /php/Editor/Editor.php(803): DataTables\Editor\Field->optionsExec(Object(DataTables\Database)) 1 /php/Editor/Editor.php(555): DataTables\Editor->_get(NULL, Array) 2 /table.bookings_dm.php(120): DataTables\Editor->process(Array) 3 {main} thrown in <b>/php/Editor/Field.php</b> on line <b>593</b><br />

Can someone help me please? Show me a way because I really have not changed anything in the files.

Best


select extension apply only selected columns??

$
0
0

select extension apply only selected columns??.

is it possible.?

how to use mergeCells

Adding text to the search input.

$
0
0

I have the following scenario

I have a Main Customer datatable.
When I click on a row It runs the following

$('#dtCustomers').on( 'select.dt', function ( e, dt, type, indexes ) {

      selectedCustomerID = tableCustomers.cell('.selected', 0).data();

          if (currentCustomerID !== selectedCustomerID )
            {
                getInvoices();
                getContacts();
                getCalls();
                currentCustomerID = selectedCustomerID;
                selectedCompanyName = tableCustomers.cell('.selected', 1).data();
                selectedAddress1 = tableCustomers.cell('.selected', 8).data();
                selectedAddress2 = tableCustomers.cell('.selected', 9).data();
                selectedAddress3 = tableCustomers.cell('.selected', 10).data();
                selectedTown = tableCustomers.cell('.selected', 11).data();
                selectedPostCode = tableCustomers.cell('.selected', 12).data();

                selectedDocType = 'Invoice';
            }
     } );

This then populates / filters the other tables.

I have another datatable which lists all the invoices and it allows me to find an invoice by number and select it for printing / amdending.

When I click on this I want 'action' the above.

I have

    $('#dtAllInvoices tbody').on( 'click', '.getInvoice', function () {

    var tr = $(this).closest('tr');
        if ( $(tr).hasClass('child') ) {
        tr = $(tr).prev();
    }
        var data2 = [tableAllInvoices.row( tr ).data()];

        selectedCustomerID = data2[0].invoice.CustID;
        selectedInvoiceID = data2[0].invoice.InvID;
        currentCustomerID = 0;
        console.log('selectedCustomerID = '+ selectedCustomerID);
        tableCustomers.columns( 0 ).search( selectedCustomerID ).draw();

        ChangeForm(Form1, "fade", "fade", 500);


                $('#dtCustomers tbody tr:eq(0) td:eq(0)').click();
                tableInvoices.columns( 0 ).search( selectedInvoiceID ).draw();

                selectedDocType = 'Invoice';

});


}

So I get the Customer datatable filtered to one customer
The click works and repopulates everything
And the Invoice table is filtered to the selected invoice number.

The only issue is the customer datatable has only one row and I need a 'reset the search' button.
( what is the syntax to clear search ?).

A better approach would be instead of

tableCustomers.columns( 0 ).search( selectedCustomerID ).draw();

populate the search input with the company name so I can then clear the search box when finished.

So how do I populate the search input with text and trigger it ?

Cheers

Steve Warby

Set input button to have ‘X’ to clear.

$
0
0

I’m sure I’ve asked before but can’t find it.

Is there a way to make this wizardry

DataTable components bootstrap

$
0
0

after following the link https://datatables.net/examples/basic_init/scroll_y_dynamic.html expected the table layout to be constant for all the screen resolutions
But the table opened in different screens, the footer part marked in orange border is becoming large for large screens and same case for the data part marked in yellow(becomes smaller).


.DataTable({ "scrollY": "70%", "scrollX": false, "showNEntries": true, "scrollCollapse": false, "autoWidth": true, "sAjaxSource": urlDataRetrieval, "sAjaxDataProp": "", "searching": true, "pageLength": 50, "order": [ [0, "asc"] ],

Is there any make the header,middle part and footer part of the table occupies constant percentage according to the screen automatically?

Screen shot

Get column name by index

$
0
0

Is there a way to get a column name (i.e., the name defined using columns.name option), which is more direct than the following one?

var exampleIndex = 3;
var columnName = table.settings().init().columns[exampleIndex].name;

Download option using pagination

$
0
0

Currently im using pagination . When i download the data into excel ,i am not able to get data from other page.I am only getting the data on that specific page . How to solve this problem ?


displayStart works but results in incorrect page 'selected' button bottom right

$
0
0

I am using displayStart to show records starting from 13 from a table with 32 records.

Table displays the default 10 records per page.

The resultant table displays from record 13!

However... the default paging buttons (bottom right) reads 3. I would expect this to be 2.

As an extra test, I tried table.page.info().page reads correctly '1' (counting from 0, is what I expect). Why is th paging button on 3? Is this a bug?

Is the value denoting the 'selected' page derived from the upper bound of the rows starting from 13 (13+10=23), which might explain the anomaly, in which case it would be a bug.

What do you think?

Sample code below.

$('#example').DataTable({

    dom: "Bfrtip",
    ajax: {

// Working Ajax
},
displayStart: 13, // Display from Row
order: [[ 1, 'asc' ]],
columns: [
{
data: null,
defaultContent: '',
className: 'select-checkbox',
orderable: false
},
// some other columns

    ],
    select: {
        style:    'os',
        selector: 'td:first-child'
    },
    buttons: [
            {
                text: 'info',
                action: function( e, dt, node, config ){

console.log(table.page.info());
console.log('the page we want to return to is: '+table.page.info().page);
}
},
{ extend: "create", editor: editor },
{ extend: "edit", editor: editor },
{ extend: "remove", editor: editor }
]

});

Warning (tech-note 4) fired for empty cells (not null nor undefined, simply = '')

$
0
0

I'm using DataTables-1.10.16.

All works fine with Firefox and Chrome.

But with IE11 I get the DataTables warning: table id={id} - Requested unknown parameter '{parameter}' for row {row-index}, column{column-index}.
It clearly appears for each cell having content = ''.
The warning fires not only when initially displaying the table content, but also each time a cell content is changed to ''.

Since it happens with IE11 only, my first guess was about a comma after the last member of an object or array. But:
* IE uses to fire a console alert when it happens, and it's not the case here
* nevertheless I carefully checked for that and didn't found anything
* and actually, regarding the tech-note suggestion about if using dt-init columns, my dt-init is dynamically populated by push() so no additional comma can appear

Then I examined the very content of the involved cells. But:
* their content comes from a source that I can console.log() and they well appear as a simple empty strings, not undefined nor null.
* anyway, in case there is some unidentified bug in my code when the data is processed between source and DataTable.row.add(), I just tried to add defaultContent: '' to each of the dt-init.columns members, and it keeps firing the warning.

So now I feel totally stuck: what else should I examine to explain what is happening?
TIA.

Auto-Save feature – where is it?

DataTables (1.10.16) export to pdf tool bar button is not working in IE 11 running in IE 10 mode.

$
0
0

The export to pdf button in datatable is not working for me in IE 11 running in IE 10 mode. If I run in Edge mode using developer tools, it works fine. I am using Buttons plugin 1.4.2. My setup info is here - https://debug.datatables.net/uporoc

I get InvalidStateError in datatables.js. I cannot change IE to run in Edge mode as its controlled by master page. Are there any workarounds?

Wait until function is complete while Table is generating

$
0
0

I made a Table with Ajax and setting the columns like this:

var table = $('#customerTable').DataTable({
        "ajax": {
            "url": "api.php?getUsers&type=customers",
            "type": "GET",
            "dataSrc": ""
        },
        "columns": [
            { "data" : "id" },  // Get User ID
            { "data" : "email" },   // Get User Email
            {
                // Convert Usergroup
                "data" : "usergroup",
                render: function(data){
                    ConvertUserGroup(data).done(function(){
                    });

                }
            },

In my DataBase, usergroup is the id of a group which is in another Mysql table (for example -> 1, 2 or 3).

So I want to convert these numbers into a Bootstrap Badge, thats why i do this line:

ConvertUserGroup(data).done(function(){
});

And the function contains this:

// Convert Account Status
function ConvertUserGroup(usergroupID) {
    $.ajax({
        url: "api.php?getGroups&single="+usergroupID,
        type: "GET",
        dataType: "json",
        success: function(data){
            var returnString = '<span class="badge badge-'+data.groupcolor+'">'+data.groupname+'</span>';
            console.log(returnString);
            return returnString;
        }
    });
}

But this isn't working because i can't use two Ajax methods at once. I can't find a callback for render.

So my Question is, how can i tell to ajax in DataTables (while the columns are creating) that it has to wait until ConvertUserGroup() is finished?

datatable is not displaying the rows

$
0
0

Datatable is not displaying any rows. using datatable debugger & Browser developer tools, I checked the ajax request is getting the data in json format without any issues. Here's my code. Please help

CSHTML


` <div style="margin:0 auto;"> <table id="companies-table" class="table table-striped table-bordered table-hover responsive"> <thead> <tr> <td>Id</td> <td>Name</td> <td>Address</td> <td>City</td> <td>State</td> <td>Country</td> <td>ZipCode</td> <td>Phone</td> <td>Email</td> <td>Status</td> </tr> </thead> <tbody></tbody> <tfoot> </tfoot> </table> </div> `
JavaScript
`
<script src="https://cdn.datatables.net/1.10.16/js/jquery.dataTables.min.js"></script>
    <script src="https://cdn.datatables.net/fixedheader/3.1.3/js/dataTables.fixedHeader.min.js"></script>
    <script>
        $(document).ready(function () {

            var table = $('#companies-table').DataTable({
                processing: true,
                serverSide: false,
                fixedHeader: true,
                "ajax": {
                    "url": "/Company/GetAllCompanies"
                },
                columns: [
                    { 'data': 'CompanyId' },
                    { 'data': 'CompanyName' },
                    { 'data': 'Address' },
                    { 'data': 'CityName' },
                    { 'data': 'StateName' },
                    { 'data': 'CountryName' },
                    { 'data': 'ZipCode' },
                    { 'data': 'Phone' },
                    { 'data': 'Email' },
                    {'data': 'Status'}
                ]
            });

        });
    </script>
`

Ajax Output Based on Datatable Debugger & Browser Developer Toolbar

`
[{"CompanyId":1,"CompanyName":"Unsipegicator Direct Company","Address":"HRGM1S45G9L67Z121","CountryName":"Mozambique","CityName":"Kingston upon Hull","StateName":"Colorado","ZipCode":"10369","Email":"roilood.fsxh@hsztqt.org","Phone":"297-4192231","Fax":"925067-5684","Status":true},{"CompanyId":2,"CompanyName":"Klieraquover Holdings ","Address":"M9V74RCKV0ZQC","CountryName":"Dominica","CityName":"London","StateName":"Oregon","ZipCode":"62786","Email":"gplf196@cwjhcsppm.neqtxx.com","Phone":"190236-1407","Fax":"739-913-2879","Status":false}]
`

Responsive issue with _resizeAuto() and CSS min-width

$
0
0

I'm trying use CSS to set a min-width for my columns, but when I do this the table's responsiveness is broken. I've tracked the problem down to the _resizeAuto() in the Responsive plugin.

The problem is the code creates a clone of the table and the headers and strips the min-width from the clone. When it does this, the minWidth property it calculates for each column ends up being different than the CSS enforced min-width actually on the table.

When _columnsVisiblity() runs, it's calculations end up all being wrong, so the columns do not resize and hide based upon the actual min-width of the column.

If I change the following lines in the _resizeAuto() function:

        var headerCells = dt.columns()
            .header()
            .filter( function (idx) {
                return dt.column(idx).visible();
            } )
            .to$()
            .clone( false )
            .css( 'display', 'table-cell' )
            .css( 'min-width', 0 );

... and remove the css( 'min-width', 0 ) to make it:

        var headerCells = dt.columns()
            .header()
            .filter( function (idx) {
                return dt.column(idx).visible();
            } )
            .to$()
            .clone( false )
            .css( 'display', 'table-cell' );

The code works as expected.

Why is it overriding the min-width property?

Is this something that can be changed?

Is there a better way to set a minimum width for a column?


Best way to prevent column widths from changing after sort

$
0
0

I'm using the Responsive extension so my column resize and play nicely at different resolutions. One of the usability issues I'm running into is the column width can change when I click a column to change the sort order.

I know I can wrap the table in the "nowrap" class, but that's not the behavior we're after.

What I really want is for columns to have a minimum width and for text that doesn't fit in the column to have a text-overflow with an ellipsis.

I've been able to accomplish what I want by doing the following:

  1. Adding an inner div (.datatable-column-width) to each cell w/a the text overflow rules (i.e. overflow: hidden; text-overflow: ellipsis; white-space: nowrap;)
  2. Setting an min-width to each .datatable-column-width element
  3. Attaching a column-sizing.dt event which: (a) sets the width of each header to it's current width (this shouldn't be necessary, but seems to be required) and (b) updating the max-width for each .datatable-column-width element to match it's heading width (using instance.column(idx).nodes()).

This works, but it's pretty expensive because it has to loop through every cell in the table each time the resize event fires.

I could speed things up by building dynamic classes and then updating those styles instead of updating the property on each cell directly. That should speed things up quite a bit.

However, before I do that, does anyone else have a better solution?

(NOTE: I'm also doing something similar so I can create columns with a fixed width. I have some columns where I want to set a specific width for the column and setting the width, min-width and max-width on the cell data seems to be the only way to reliable do this.)

Trying to Load JSON on DataTable

$
0
0

Hi!

I'm trying to use a JSON to load datatable rows, but the datatable always return me a error, that is: DataTables warning: table id=dt_basic - Requested unknown parameter 'id' for row 0, column 0. For more information about this error, please see http://datatables.net/tn/4

I get this JSON from the InitComplete function from another datatable e save the result on sessionStorage. Like this:

"initComplete": function (settings, json) {
sessionStorage.setItem('json', json);
}

The JSON returns me:

[{"id":"36566","nomeFantasia":"LOJAO DOS ALUMINIOS","titulo":"Ajuda para gerar e corrigir arquivo do Sped Fiscal","codigoPrograma":"9220","nome":"ALANO","status":"Aberto","dataAbertura":"11-12-2017 00:00","motivo":"Comercial"}]

my columns configuration is:

"aoColumns": [
{"data": "id"},
{"data": "nomeFantasia"},
{"data": "titulo"},
{"data": "codigoPrograma"},
{"data": "nome"},
{"data": "status"},
{"data": "dataAbertura"},
{"data": "motivo"},
{"data": function (data) {
if (data.status == 'Fechado') {
return '<a style="width: 100%" class="btn btn-primary btn-sm" title="Trâmite" id="editChamado" href="#ajax/chamados-edit.php?id=' + data.id + '&st=0"><i class="fa fa-edit"></i></a>'
} else {
return '<a style="width: 45%" class="btn btn-primary btn-xs" title="Trâmite" id="editChamado" href="#ajax/chamados-edit.php?id=' + data.id + '&st=1"><i class="fa fa-edit"></i></a><a style="margin-left: 5%; width: 45%;" title="Fechar" id="deleteChamado" href="#ajax/chamados-delete.php?id=' + data.id + '&acao=delete" class="btn btn-success btn-xs"><i class="fa fa-check"></i></a>';

                            }
                        }
                    }
                ]

my table:

Chamado Nome Fantasia Título Codigo Rotina Atendente Status Data Abertura Motivo Ação

Please, anyone send me a ligth!
Thank you!

$.each in render function

$
0
0

I want to Convert my column.data. So I load the results from the convert before i call the table to load:

function test(){
    return $.ajax({
        url: "../api.php?getGroups",
        type: "Get",
        dataType: 'json',
        success: function(data) {
            console.log(data);
        }
    });
}
// Load Table Data
$(document).ready(function() {
    $.when(test()).done(function(a1){
    var table = $('#customerTable').DataTable({
        "ajax": {
            "url": "../api.php?getUsers&type=kunden",
            "type": "GET",
            "dataSrc": ""
        },
        "columns": [
            {
                // Format Date
                "data" : "created_at",
                render: function(data) {
                    return moment(data).format('LLL')
                }
            },
            {
                // Convert Usergroup
                "data" : "usergroup",
                render: function(data){
                    $.each(a1, function(i, v) {
                        if(v.id == data){
                            return v.groupname;
                        }
                    });
                },
                "defaultContent": "<i>Not Set</i>"
            },
          [....]

But the $.each doesn't work. Everytime i will get the "defaultContent". How can I return $.each results inside render ?

How to give title as bold in excel export, Need to give border for entire data exported in excel

$
0
0

Hi Team,

I'm new to datatables, It has various features. I have few questions how to achieve the below scenarios, could you guys guide me on this.

  1. Firstly i want to give the title as bold in the Excel export.

title: '<b>Enquiry Breakup</b>'

if i give as above it is priting with html tags in the excel export

  1. Need to give border for entire table exported as excel.

I have gone through below post
https://datatables.net/extensions/buttons/examples/html5/excelBorder.html
But it gives border to only one particular row . But i want the border for the entire data exported to excel.

3.The $ symbol for is displaying after the amount. I need the $ symbol to be exported as prefix of the amount.

  1. I need all the columns data to be align left.

Can anyone of you guide me on above items.

Waiting for the response

Thanks,
Sravani.

Server Side Error shown

$
0
0

How can i show a server-side error that send with json to the datatables. The error looks like this format:

{
    "type": "error",
    "icon": "fa fa-exclamation-triangle",
    "title": "404, Not Found",
    "text": "\r\n\t\t\t<p class=\"margin-left-5\">\r\n\t\t\t\t<span class=\"text-black weight-600\">Time:<\/span> 17.December 2017 17:37:36<br \/>\r\n\t\t\t\t<span class=\"text-black weight-600\">API:<\/span> \/meet\/88a9135f-7f17-467b-ad9b-7b7b8037a964\/clubs<br \/>\r\n\t\t\t\t<span class=\"text-black weight-600\">Message:<\/span><br \/>The requested resource could not be found but may be available in the future. Subsequent requests by the client are permissible.\r\n\t\t\t<\/p>"
}

i read something with this:

$.fn.dataTable.ext.errMode = 'throw';

        evlist.on(
            'error.dt', function( e, settings, techNote, message ) {
                console.log(e);
            } );

but i can not read the json to display it.

Andreas

Viewing all 81798 articles
Browse latest View live


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