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

Is there a way to load a row from ajax after datatable loads bu using username or id ?

$
0
0

Hi, i want to load a row of datatable from ajax. I'm loading datatable from server side with ajax but i also want a row to get value after initialization and get value against username or id then fill the empty column rows with value with ajax data.


searching not working in server side proccessing without ssp library

$
0
0

when i try to implement server side processing without ssp library, my search field value not getting in ['search']['value'].

draw: 22
columns[0][data]: user_id
columns[0][name]:
columns[0][searchable]: true
columns[0][orderable]: true
columns[0][search][value]:
columns[0][search][regex]: false
columns[1][data]: name
columns[1][name]:
columns[1][searchable]: true
columns[1][orderable]: true
columns[1][search][value]:
columns[1][search][regex]: false
columns[2][data]: email
columns[2][name]:
columns[2][searchable]: true
columns[2][orderable]: true
columns[2][search][value]:
columns[2][search][regex]: false
columns[3][data]: mobile
columns[3][name]:
columns[3][searchable]: true
columns[3][orderable]: true
columns[3][search][value]:
columns[3][search][regex]: false
columns[4][data]: designation
columns[4][name]:
columns[4][searchable]: true
columns[4][orderable]: true
columns[4][search][value]:
columns[4][search][regex]: false
columns[5][data]: gender
columns[5][name]:
columns[5][searchable]: true
columns[5][orderable]: true
columns[5][search][value]:
columns[5][search][regex]: false
columns[6][data]: status
columns[6][name]:
columns[6][searchable]: true
columns[6][orderable]: true
columns[6][search][value]:
columns[6][search][regex]: false
columns[7][data]: created_at
columns[7][name]:
columns[7][searchable]: true
columns[7][orderable]: true
columns[7][search][value]:
columns[7][search][regex]: false
order[0][column]: 0
order[0][dir]: asc
start: 0
length: 10
search[value]: tes
search[regex]: false

How do I get a hidden td element?

$
0
0

HTML:

<table id="table">
    <thead>
        <tr>
            <th>Index</th>
            <th>Some headline</th>
        </tr>
    </thead>
    <tbody>
        <tr>
            <td data-link="somelink">1</td>
            <td>Some information</td>
        </tr>
    </tbody>
</table>

JavaScript:

var table = $('#table').DataTable({
    'columnDefs': [
        {'targets': [0], 'visible': false}
    ]
});

$(document).on('click', '#table tbody tr', function () {
    let td = table.row(this).data()[0];
    //get data-href attribute???
});

With this I just get the text inside the hidden td (number 1). But I actually like to have to whole td or atleast access the data-link attribute.
How do I achieve this? Thanks

Get count of filtered rows

$
0
0

Hi, is there any api or method to get count of filtered data ? Like we have PageInfo.pages, PageInfo.recordsTotal etc.

SSP and row.add().draw() again

$
0
0

I am aware of what's the purpose and what's going on after calling row.add().draw() with SSP but...

I have an application which uses DataTables for displaying relational data within edit form of the object. I'm migrating it to SSP now for it started to use large number of records and it all works fine but..
The very core structure of the app is based on serialising and saving the form after the button 'save' is clicked. Each row of the 'relation-displaying' table contains hidden field with relational object ID. This whole DT-table is then serialised and send to the server for further processing.
When I want to add sth to the relation there is a modal window to let me select what's to be added. Up to now the new "rows" were appearing within appropriate DT on the screen. Clicking 'save' I was confirming it, sending to the server for further processing and displaying everything again from updated datasource.

QUESTION:
What would be your suggestion for such 'two-steps' relational "row (data)" adding after changing it all to SSP?

Of course I can add it server side but then I'm losing the 'confirmation' stage. All the same if I save just the 'relationship' data it will be wrong for the whole UI...

Any suggestions? Thank you in advance!

I implement the csv import function on the 15 day trial version but only the last record is imported

$
0
0

Only the last record in my CSV files is imported.
Please let me know if this is a limitation on the trial version or papa parse plugin?

What's the right way to map response values to DT?

$
0
0

According to the manual, DT expects the response to have certain values. However, if the server can't be made to change those parameters but does contain the information, how can I map the response to fields that DT is expecting? For example, DT expect to see {recordsTotal: 14} in the response, but my server wants to send {totalElements:14}. Is there an way to map that value to the expected parameter?

DataTables presenting with a card view

$
0
0

I have seen lots of discussion on trying to get datatables to present in a "card" or "panel" type view. I see there are lots of workarounds utilizing the various callbacks and events. I believe i have found the simplest method yet.

My method relies solely on CSS. Heres a few screen shots and a link to a sample page.
azguys.com/datatables/index.html

I have tested it out on Chrome and IE, they both seem agreeable to the CSS, no funny quirks. Give it a try and let me know what you think, and if it may have problems of other browsers.


Event ajax error

$
0
0

How use ajaxError handler if server responde 403 error?

Uncaught TypeError: $.fn.dataTable.Editor is not a constructor

$
0
0

Sir, My webpages were working fine till noon after that I'm getting following error -

Uncaught TypeError: $.fn.dataTable.Editor is not a constructor

Going through the errors reflected in developer mode of browser, it transpired that something was wrong with editor files. However, the files related to editor are intact for may a days.

A snippet of developer mode is as under ;

dataTables.editor.min.js:12 Uncaught SyntaxError: Unexpected token '.'
jquery-3.3.1.js:3818 jQuery.Deferred exception: $.fn.dataTable.Editor is not a constructor TypeError: $.fn.dataTable.Editor is not a constructor
at HTMLDocument.<anonymous> (https://e-reporting.in/Data/RTC/index.php:3112:16)
at mightThrow (https://e-reporting.in/js/jquery-3.3.1.js:3534:29)
at process (https://e-reporting.in/js/jquery-3.3.1.js:3602:12) undefined
jQuery.Deferred.exceptionHook @ jquery-3.3.1.js:3818
process @ jquery-3.3.1.js:3606
setTimeout (async)
(anonymous) @ jquery-3.3.1.js:3640
fire @ jquery-3.3.1.js:3268
fireWith @ jquery-3.3.1.js:3398
fire @ jquery-3.3.1.js:3406
fire @ jquery-3.3.1.js:3268
fireWith @ jquery-3.3.1.js:3398
ready @ jquery-3.3.1.js:3878
completed @ jquery-3.3.1.js:3888
jquery-3.3.1.js:3827 Uncaught TypeError: $.fn.dataTable.Editor is not a constructor
at HTMLDocument.<anonymous> (index.php:3112)
at mightThrow (jquery-3.3.1.js:3534)
at process (jquery-3.3.1.js:3602)

I am hapless ..Please guide.

line break when exporting to excel

Editor datetime not set to the displayFormat when opening in Edit mode

$
0
0

I have a table that has two dates on it, FROM and TO. When I set the displayFormat the formatting is not properly set on the load of an edit for a record (see FROM field). Upon selecting a date from the DatePicker (see TO field), it does show up correctly. See here:

The code for loading the editor is here:

        pricesTableEditor = new $.fn.DataTable.Editor({
            ajax: pricesTableUrlUpdate,
            table: "#tblSeminarPrices",
            idSrc: "Id",
            fields: [
                { label: "Seminar Price Id:", name: "Id", type: "display" },
                {
                    label: "Seminar Id:", name: "FkIdSeminar",
                    type: "display",
                    def: function () {
                        return pricesTableSeminarIdToCreateFor;
                    }
                },
                {
                    label: "From:", name: "PriceFrom",
                    type: "datetime",
                    displayFormat: "YYYY-MM-DD",
                    fieldInfo: 'This will be set to the START of the selected day.',
                    def: function () { return new Date(); },
                },
                {
                    label: "To:", name: "PriceTo",
                    type: "datetime",
                    displayFormat: 'M/D/YYYY',
                    fieldInfo: 'This will be set to the END of the selected day.',
                    def: function () { return new Date(); },
                },
                {
                    label: "PriceFull:", name: "PriceFull",
                    type: "text",
                    fieldInfo: "This should be in the XYZ.XX format."
                },
                {
                    label: "PriceMulti:", name: "PriceMulti",
                    type: "text",
                    fieldInfo: "This should be in the XYZ.XX format."
                },
                {
                    label: "AllowMulti:", name: "AllowMulti",
                    type: "checkbox",
                    separator: "",
                    options: [{ label: '', value: true }],
                    unselectedValue: false,
                    fieldInfo: "Check to allow multi-discount with this pricing."
                },
            ],
            formOptions: {}
        });

(And yes, I know the FROM and TO date formats are different, I was trying different things to make it work.)

The ajax data that comes from the database (postgresql) is this:

{
    "data": [
        {
            "Id": 4379,
            "FkIdSeminar": 4881,
            "PriceFrom": "2019-04-01T00:00:00",
            "PriceTo": "2019-12-31T00:00:00",
            "PriceFull": 65.0,
            "PriceMulti": 40.0,
            "AllowMulti": true
        }
    ]
}

What do I need to do to get the dates to show correctly on a Load?

Here is a JSBin to show the problem...
http://live.datatables.net/memifume/1/edit

Thanks!

Scroller is showing paging buttons

$
0
0

Hello! I have this configuration of datatables:

    "datatables.net": "1.10.19",
    "datatables.net-bs4": "1.10.19",
    "datatables.net-responsive-bs4": "2.2.3",
    "datatables.net-scroller": "2.0.0",

and the options object

{
      lengthChange: false,
      info: false,
      searching: false,
      scrollCollapse: true,
      scrollY: 600,
      scrollX: true,
      deferRender: true,
      responsive: true,
      paging: true,
      procesing: false,
      scroller: {
        loadingIndicator: true
      },
}

I don't understand why it shows the paging buttons when I enable scroller extension. When in this comment it says that it is impossible to happen...

https://datatables.net/forums/discussion/comment/63105/#Comment_63105

Thank you for helping!

Help - datatables return UTF-8 BOM character before json string.

$
0
0

Hi, please help.

Datatables returns the "ď» ż "character in json_encode, exactly the" U + FEFF" (hexadecimal "EF BB BF") character as the beginning of the JSON string.
The character is just before {"draw": 0, ...} in the result code from the "ssp :: complex" class.
It's first char.

Error from datatables js parser: "DataTables warning: table id=tabela - Invalid JSON response. For more information about this error, please see http://datatables.net/tn/1"

What could be the reason for this?

I attach a file with this sign.
Please help me how to remove it from the string.
I just have to remove it from json string.

Modify heading content when printing

$
0
0

Have a simple table I'm displaying to the screen. When I click the Print button, I'd like to change the text of some of the header columns. For example, on the screen, I have a column labelled "ABC". On the printout, I'd like the column to be labelled "XYZ",
As always TIA,
Mike


Having trouble with data table responsive and child row.

$
0
0

I know this similar topic is here a lot, and I've read and tried most examples, but I am unable to get the exact desired result.
summary of what I want: Data table - if row has a 'note'.. display it as a child row, open automatically with no option to close. if note = ''.. then do not display a child row. AND have table be able to show and hide columns based on size but never become a child. 'note' should only ever be the child.

<table id="account_history" class="display table table-bordered table-sm" width="100%">
    <thead>
        <tr class="text-nowrap">
            <th>Date</th>
            <th>Time</th>
            <th>Uder ID</th>
            <th>Code</th>
            <th>Description</th>
            <th>Desk</th>
            <th>Next Rvw.</th>
            <th>Status</th>
            <th class="none">Note</th>
        </tr>
    </thead>
    <tbody>
    </tbody>
</table>


<script type="text/javascript">
$(document).ready(function(e){
    
        var base_url = "<?php echo base_url(); ?>";
    var account  = "<?php echo $this->account_number; ?>";

    var table = $('#account_history').DataTable({
        "responsive": {
            details: false,
        },
        "order": [[0, "desc" ]],

        "ajax":{
            url :  base_url+'account/'+account+'/history',
            type : 'POST',
            "dataSrc": function (myJson) {
                if(myJson == "TIMEOUT")
                { window.top.location.href = base_url+'logout'; return; }
                return myJson.data;
            }
        },

        columns: [
            { data: 'date',     name: 'date',       orderable: true },
            { data: 'time',     name: 'time',       orderable: false },
            { data: 'user_id',  name: 'user_id',    orderable: false },
            { data: 'acc_code',   name: 'acc_code', orderable: false },
            { data: 'desc',     name: 'desc',       orderable: false },
            { data: 'desk',     name: 'desk',       orderable: false },
            { data: 'next_rvw',    name: 'next_rvw',    orderable: false },
            { data: 'status',           name: 'status',     orderable: false },

            { data: 'note',     name: 'note',       orderable: false, visable: false }
        ],

    }); //account_history

    $("#account_history").DataTable().rows().every( function () {

        var tr = $(this.node());
                var row = table.row( tr );
        var d = row.data();
        this.child(
                '<div class="table-responsive">'+
                    '<table class="table table-bordered table-sm mb-0">'+
                        '<tr>'+
                            '<td class="border-top-0 p-0">'+d.note+'</td>'+
                        '</tr>'+
                    '</table>'+
                '</div>'
        ).show();
        tr.addClass('shown');
    });

}); // End Document Ready Function
</script>

I have versions working with controls in column 0 using an on click function to open and created row function if (data.note === '') to not display the +/- icon, but i cannot combine all these functions to find my explained effect.
Please help if you can
Thanks
Brian

Handling multiple errors on Excel/CSV import?

$
0
0

Hey, I have a case where people are using Editor to upload Excel files. That's been working fine for a long time, but, apparently they're routinely uploading files where many of the rows are bad, and they want to see the list of which rows are bad rather than having the processing croak on the first bad one. Worst case, I stuff the bad rows + error messages into some new table and give them a way to view that, but is there an easier way to do this in Editor?

My first thought was that I might be able to stick multiple errors into the response expected by the file upload stuff here, but it doesn't look like it supports multiple errors per file.

My second thought was to switch to CSV and use the CSV import here (which I've had success with in other projects), which I think does a multi-edit post instead of a "file upload", but it looks like that doesn't support row-level errors either (and can't; there's no place for them in the response from the server).

To see this in action, on that CSV import example page, if you hit Export CSV, edit the file (remove the first name from a few rows, and the last name from a few other rows), and then Import CSV, you get the normal multi-edit form with "Multiple values" given for the various fields (all good so far), but when you hit Submit, you get just the field-level errors: "A first name is required" under "First name," and "A last name is required" under "Last name," with no way to tell which rows were the problem.

Thoughts?

jQuery DataTables RowReorder - disable row from being sorted/reordered

$
0
0

I want to be able to disable a row from being reordered.

The behavior that I want is that when I am dragging rows to be reordered, I want the row to stay at the bottom position and never be reordered.

I was able to set it up such that this row cannot be selected for reordering; however, other rows can be placed underneath.

I also tried to set things up where I remove the row from the table while reordering happens; however, this causes some issues where some of the rows disappear.

NULL on Editor Radio Button OPtion

$
0
0

I cant do this:

                                                "label": "Status:",
                                                "name": "status",
                                                    type:  "radio",
                                                    "options": [
                                                        { label: "Yes", value: 1 },
                                                        { label: "NO!", value: 0 },
                                                        { label: "Not Applicable", value: null }
                                                    ]

Should it be possible? The NA option keeps telling me the integer value is no allowed. (DB field set to Tiny Int, with NULL allowed.)

thanks

Hardcode File Save Location And File Name

Viewing all 82760 articles
Browse latest View live


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