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

stateSave +serverSide pagination bug when page no longer has records

$
0
0

Let's say there are a total of 3 pages and I am using stateSave and serverSide. I go to the last page, so datatables remembers my last page was 3. I then delete the only record on that page. I then go back to my datatable. The 3rd page is now gone from the pagination menu, and it is telling me "No matching records found".

I tried fixing this by using the API:

if (api.page() > 0 && api.rows({page: 'current'}).count() === 0) {
    // set page to previous
    api.page('previous');
    // call draw() so state saves
    api.draw();
    // reload the table
    api.ajax.reload();
}

This does not correct the issue. It bugs out and then I have to manually refresh the page to get it to jump back to page 1. Ideally I would like it to simple go back 1 page and then redraw the table/pagination.

How do I correct this?


datatable export to excel upon IE Edge

$
0
0

Hi Everyone,
i am unable to export data into excel option while using IE 11, otherwise it is working fine.

IE 11:
it shows error:
Excel completed file level validation and repair. Some parts of this workbook may have been repaired or discarded.
Replaced Part: /xl/worksheets/sheet1.xml part with XML error. A qualified name cannot contain multiple colons. Line 1, column 1204.

XML problem:
<?xml version="1.0" encoding="UTF-8" standalone="true"?>

-<recoveryLog xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main">

<logFileName>error067440_01.xml</logFileName>

<summary>Errors were detected in file 'C:\Users\ANCP3\AppData\Local\Microsoft\Windows\INetCache\IE\1DH533I0\1 System 4 Health.xlsx'</summary>

-<additionalInfo>

<info>Excel completed file level validation and repair. Some parts of this workbook may have been repaired or discarded.</info>

</additionalInfo>

-<removedParts summary="Following is a list of removed parts:">

<removedPart>Replaced Part: /xl/worksheets/sheet1.xml part with XML error. A qualified name cannot contain multiple colons. Line 1, column 1204.</removedPart>

</removedParts>

</recoveryLog>

I will be thankful if there is any good suggestion for me

Want to know how the search functionality works.may b silly but i need ans plz

$
0
0

If I have 500 records in a table,and each page contains 50 records 10 pages.If i search in first page results will come from all pages or that particular page ?? Quick reply please !

Can we include search input in header & footer with vertical scroll and not horizontal scrollbars?

$
0
0

I want to create a table with col search and fixed height to show many records in length even.But im not getting it , when i click on the search input its disappearing. got some idea its been reflecting on DOM structure. can anybody help asap??

Problem with dynamic loading of data.

$
0
0

Hi all, I am new to DataTables (DT) and experimenting with its functionality.
In my first test I used Data (DT) to format a preloaded table and then inserting rows to the table.
I am now trying to load data by fetching the data from the server as json table and then use DT to load and format the data and here I am getting a problem that I have not been able to resolve.
The code fragment is as follows:

jQuery.ajax({
type:"POST",
url: ajaxurl,
})
.done(function(data){
// parse json response to object
var customer_data = JSON.parse(data);
console.log(customer_data);
console.log(customer_data[0]);
console.log(customer_data[0].id);
console.log(customer_data[0].name);
console.log(customer_data[0].phone);
console.log(customer_data[0].email);
console.log(customer_data[0].address);
// load customer table
//document.getElementById("feedback").innerHTML = c1+" "+c2+" "+c3+" "+c4+" "+c5+" ";
(function($) {
$('#cTable').DataTable( {
"data": customer_data,
"columns": [
{title: "id"},
{title: "name"},
{title: "email"},
{title: "phone"},
{title: "address"}
],
"scrollY": 200,
"scrollX": true
} );
})( jQuery );
…..
With the above code DT issues the following error message 2 tmes:

“DataTables warning table id=cTable – Requested unknown parameter ‘0’ for row ‘0’, column 0. For more information about this error, please see http://datatables.net/tn/4”

Continuing the table has been formatted but no data are available.

My understanding is that the problem relates to the data, that’s the reason for the console log that comes correct:

Array(41) [ {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, … ]
Object { id: "1", name: "James Bruce", email: "jamesbruce@makeuseof.com", phone: "2147483647", address: "London England" }
1
James Bruce
2147483647
jamesbruce@makeuseof.com
London England

Any idea what am I doing wrong?
Any assistance will be very much appreciated.

Best Regards, Dimitris

Secondary sort criterium always in ascending order

$
0
0

How would I make my secondary sort always ascending? For example:

{ targets: [1], orderData: [1, 0] }

I want my col0 to be sorted ASC no matter how col1 is sorted (for the same values in col1, of course).

Datatable is not a function, cant recognize js

$
0
0

First of all, I would like to say that I know this is a question that comes up quite often and has been discussed many times.
But despite that, I can not solve it ...

I think I have declared my sources with jquery first and then datatable but when I load the web page I always have the same error message:

Uncaught SyntaxError: Unexpected token { jQuery.Deferred exception: $ (...). DataTable is not a function TypeError: $ (...). DataTable is not a function at HTMLDocument. (https: // localhost: 44338 / Events: 87: 27) at l (https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js:2:29375) at c (https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js:2:29677) undefined

Here's a picture of the network:

Could you please help me to solve it?

Thx!

add row to datatables - requested unknown parameter

$
0
0

Hi y'all,

I'm trying to add a new row to my table with https://datatables.net/reference/api/row.add() and https://datatables.net/reference/api/rows.add().
Unfortunately I get the error request:
"DataTables warning: table id=customer - Requested unknown parameter 'crapper_customer_intranet.kundenr' for row 10, column 0."

Javasript:

         $('#customer').DataTable( {
            dom: "Blfrtip",
            ajax: {
                url: '../backend/getCustomerBack.php',
                type: 'POST',
                dataSrc: 'data'
            },
            serverSide: true,
            columns: [
                {
                    data: "crapper_customer_intranet.kundenr",
                },
                {
                    data: "crapper_customer_intranet.navn",
                },
                {
                    data: "crapper_customer_intranet.cvrnr",
                },
            ],
            select: true,

The following code is invoked when clicked on a button. I've tried several solutions from various sources who've had the same problems, but still doesn't seem to work.

                                var table = jQuery('#customer').DataTable();
                                var dataTest1 = [{
                                    "crapper_customer_intranet.kundenr":"123123123123123",
                                    "crapper_customer_intranet.navn":"15.00",
                                    "crapper_customer_intranet.cvr":"0.00"}];

                                var dataTest2 = [['sveeaaa','asdasd.00','0132123']];

                               console.log(table.rows.add(dataTest1).draw());

I've got no idea what the hell I'm missing, and it's properly just a small error I'm missing....

It gives the following error:
"DataTables warning: table id=customer - Requested unknown parameter 'crapper_customer_intranet.kundenr' for row 10, column 0. For more information about this error, please see http://datatables.net/tn/4"

I've noticed that the "row 10" is according to how many entries I've got in my table. If i change it to 50 or 100, it changes aswell..?

Here's the console log if interested.

Hope someone can help me out.

Have a great day!


How to print tables with watermark (background image) ?

$
0
0

I want to print my tables with background image as watermark.
I tried different solutions like put background to the body but nothing work.
Any help please.

Export to PDF problem in the data of table

$
0
0

Hi all
I've problem in export data to PDF, the direction of phrases not correct like the example:
before convert: word1 word2 word3
after convert to PDF: word1 word3 word2 (change words position)
The language is arabic, i've change the font to cairo for uni-coding
any help please.
Thanks in advance.

Populate Datatables Editor Select2 Options from Web API

$
0
0

I have a javascript function that returns label + value array for my select2 list. The function and it's output are as below:

    function GetEtms() {
            var actionUrl =
                '@Url.RouteUrl("DefaultApi", new {httproute = "", controller = "VariableAdditionAdmin", action = "GetEtMs"})';
            $.getJSON(actionUrl,
                function(response) {
                    if (response !== null) {
                        return response;
                      
                    }
                });

        };

Output (just dummy data for now) :

[{"label":"Please Select","value":"0"},{"label":"Some Selection Label","value":"1"}]

How do I have my datatables editor field Select2 list use this javascript function to populate?

{
                        label: "ETM:",
                        name: "EtmId",
                        type: "select2",
                        "opts": {
                            "allowClear": true                    
                        }
                    },

Previously when I was using a regular dropdown I used the below (this no longer works now i'm using select2) :

  function updateEtmDropdown() {
                var actionUrl =
                    '@Url.RouteUrl("DefaultApi", new {httproute = "", controller = "VariableAdditionAdmin", action = "GetEtMs"})';
                $.getJSON(actionUrl,
                    function(response) {
                        if (response !== null) {
                            editor.field('EtmId').update(response);
                        }
                    });

            };

            updateEtmDropdown();

I have included the select2 datatables plugin in my project.

Master Detail 2 tables on the same page? (Php/Ajax/Datatables)

$
0
0

Hello Everyone,

I got two tables on my home page.

Master Table - column names - id, location
Slave/Detail Table - column - sid, mid,update_details,

I would like to display two table

    <table id=master onclick(rowid)>

    <thead>
    <th>id</th>
    <th>location</th>
    </thead>
    </table>

    <table id=details>
    <thead>
    <th>sid</th>
    <th>mid</th>
    <th>update</th>
    <th>details</th>
    </thead>
    </table>

    function onclick(rowid)
    {
    display details table record in table id=details.
    }

Can this be achieved using datatables and ajax? if so can someone direct me to some fiddle please.

Apologize for such stupid question.

Thanking you in advance

Disabling RowGroup when all the data has the same group

$
0
0

For some of my tables I like to disable the rowGroup feature if all the data falls under the same group.

For example, I might have a page that only shows the employees at the office in London, so it doesn't add anything to show "London" in it's own row and then have every employee listed under it.

Here's how I do it:

.on("init", function() {
    var groups = table.column("[insert column name here]:name").data().unique();
    (groups.length == 1 ? table.rowGroup().disable().draw() : table.rowGroup().enable().draw());
})

This can also be easily modified to disable rowGroup if all the data is unique as well, such as when grouping on employee names, by checking the groups.length against the number of total records.

@allan, 1) I'm biased :-), but I think this would make a good example under the RowGroup extension examples on how to use the API, and 2) there is not RowGroup option in the "Ask a Question" or "New Discussion" Category dropdown.

Adding years to date of birth decrements the month by one.

$
0
0

I am adding eight years to the date of birth; however, when I do this the month decrements by one (i.e., 16/10/2010 + 8 = 16/9/2018 and 16/1/2010 + 8 = 16/0/2018).. I can get round this by adding 1 to the month. However, I am concerned that this may cause other issues. The code is:

              {"data": null, //data is null since we want to access ALL data for the sake of our calculation below
               "render": function(data,type,row) {
                   var DOB = new Date(data.dob);
                   var year = DOB.getFullYear() + 8;
                   var month = DOB.getMonth() + 1;
                   var day = DOB.getDate();
                   return (day + "/" + month + "/" + year);
                   },
              },

Also, I would like the answer returned as dd/mm/yyyy rather than d/m/yyyy.

Change the background colour based on the value

$
0
0

I am calculating the start date of an award and then want to change the background colour of the cell based on the person's age (i.e., if they are in the right age group to do the award then colour the cell. I have this:

CSS:

    .bronzeClass tr {
        background-color: #f2f2f2 !important;
    } 

datatables:

      {"data": null, //data is null since we want to access ALL data for the sake of our calculation below
               "render": function(data,type,row) {
                   var DOB = new Date(data.dob);
                   var year = DOB.getFullYear() + 8;
                   var month = DOB.getMonth() + 1;
                   var day = DOB.getDate();

                   var today = new Date();
                   var age = today.getTime() - DOB.getTime();
                   var elapsed = new Date(age);
                   var year = elapsed.getYear()-70;
                   if (year > 7 && year < 9){
                       return ('<div class="bronzeClass">day + "/" + month + "/" + year</div>')
                   }else{
                       return (day + "/" + month + "/" + year);
                   }
                 },
              },

Can we add div data to export with table?

$
0
0

i have a requirement that i need to export custom div data and table data with datatables?

Fixed header with horizontally scrollable table

$
0
0

Hi everyone

I want to have a table where the header and the leftmost column is fixed and the columns can be scrolled horizontally. I tried this:

fixedColumns: true,
fixedHeader: true,
scrollX: true

The problem is when I scroll down so the header stays fixed at top, he expands. He behaves like expected (stays the same size as the table and is horizontally scrollable) when he's not at his fixed position but as soon as you scroll down he expands to his full size.

Is there a way to make this work?

Thanks for your time

While scrolling fixed header breaks the outer max width and float over the full DOM width

Mask cell content

$
0
0

Hi all
i'm writing here because i need help for a project.
I'm developing (just for learning), web portal, and at this moment, everything is working good.

I need to know if there is some way to hide cell content (not hide column, just replace cell content with many wildcard, similar to login form ). Just clicking on wildcards is a cell, webpage will ask me for a password(popup, modal, ecc), and i have to put it to show ONLY that cell, not all cells of column.

Can you help me?

Thank you

Searchpane results in [object Object]

$
0
0

Hi,

I'm testing the SearchPane in a datatable that shows the results of an ajax JSON request.

The SearchPane has 4 columns of which 3 show correct, but 1 column results in [object Object]. I expect it's because it's a multi-select column.

Can anyone tell me how to render the content of this column correctly?

Kind regards,
nessinits

Viewing all 79514 articles
Browse latest View live




Latest Images