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

Problem with rendering a column

$
0
0

Hi

I have a problem with rendering a column. I need to convert my string into integer:

"columnDefs": [ {
"targets": 5,
"render": function ( data, type, row ) {
    return parseInt(data);
}

}],

The code works fine but I use dataTables to generate tables on multiple pages and for those pages where there are two columns, the whole table will not work. Is there a way I can make render work only for a table with a specific id? I have tried something like:

"columnDefs": [ {
"targets": 5,
"render": function ( data, type, row ) {
    if ( var table==='inventory_table' ) {
        return parseInt(data)};
     };

But it didn't work.


Adding Excel export button hides/removes the Page Length Dropdown

$
0
0

I have just started using the Data Tables.
The Page Length Dropdown comes by default while implementing the DataTable.
Recently I added the Excel Button (export feature).
The issue is that adding this button hides/removes the Page Length Dropdown.

Is there a way where we can display both the features (i.e. the button and the dropdown) as I want to implement both of this feature?
Would changing the location of these controls solve the issue and how?

Here's my sample JS code :

$('#example).DataTable(
         {
             responsive: true,

             "lengthMenu": [[10, 25, 50, -1], [10, 25, 50, "All"]],     // page length options

             dom: 'bfrtip',
              buttons: ['excel']
         });

Thank You.

Reload Table

$
0
0

Hi, i need u help again
i need reload my table after click on btn #refresh, but this not workong(

var table;
function main_table() {
  $(document).ready(function () {
        table = $('#example').DataTable({
            ajax: {
                url: '/project/all_items/',
                dataSrc: ''

            },
            "sScrollY": "90vh",
            "bPaginate": true,
            "aoColumns": [
                ...
            ],


        });
}

function refresh() {
    $('#refresh').click( function() {
        table.ajax.reload();
}

Is Bower no longer supported?

$
0
0

Today I saw the news about the 1.5.1 release of the Buttons extension. However, surprisingly in Bower is the latest version is 1.4.2, as in the GitHub repo (https://github.com/DataTables/Dist-DataTables-Buttons)

I'm using the datatables.net-buttons-bs in Bower
Am I missing something here?

Currently, I could not change to the npm version

How to search for values in a table that have a many to one relation with the table that is shown

$
0
0

I need to search for values in a table that have a many to one relationship with the main table that is show with datatables. How can I send this search information to the php server side script? I will collect the search information in a form but how can i send the form information with the ajax call that is use to update the datatables?

Scroll two datatables side by side at the same time

$
0
0

So I am a developer and I was trying to scroll two datatables at the same time but I can't catch the scoll event, someone wanna help me with this issue?

I'll attach a picture with the screen shot of the issue, I wanna scroll these two datatables at the same time and I don't know how

Editor returns

$
0
0

Okay, So if I have this straight. The editor needs the altered row data returned to it in the same format as the ajax load for the actual table right?

Show static table / datatable in editor form

$
0
0

Hello,
I have a use case where I Want to show some editor form related information (basically a tabular information) in the editor form..
but I am not able to figure out how that can be done..
Ideally the table should be displayed the the right of the form .. but on top is also okay....

any help would be really appreciated..

thanking you in advance..


select an option from a popup window

$
0
0

Hello,

I have an editor form which as a select box and a button adjacent to it....
When I user clicks the button a form with relevent information (basically a list of values) is opened and the user can select any option..

When the user selects any option from the list the list popup should close and corresponding option should be selected in the select box of editor form...

Basically, I want to allow user to be able to check all the option related information in a seperate popup (consisting of a datatable itself) and get the selected option from popup ...

Thanking in advance...

csvhtml5 exportoptions format body

$
0
0

Hello,

Looking to format one of my columns that I am exporting to a csv.

Cannot find a good example

I tried the following ... how do I format column 15 ... i tried just foobar but does not come through

Thanks,
Evan

    {extend: 'csvHtml5', text:'CSV', className:'btn-link',
     filename: 'my export ' ,
         exportOptions: {
     columns: [ ':visible' ],
     format: {
                 body: function ( data, row, column, node ) {
         return column == 15 ?
                         'foobar':
                         data;
                 }
     }
         }},

I am using
* https://datatables.net/download/#bs-3.3.7/jq-3.2.1/jszip-2.5.0/pdfmake-0.1.32/dt-1.10.16/e-1.6.5/af-2.2.2/b-1.4.2/b-colvis-1.4.2/b-flash-1.4.2/b-html5-1.4.2/b-print-1.4.2/cr-1.4.1/fc-3.2.3/fh-3.1.3/kt-2.3.2/r-2.2.0/rg-1.0.2/rr-1.2.3/sc-1.4.3/sl-1.2.3
*
* Included libraries:
* Bootstrap 3 3.3.7, jQuery 3 3.2.1, JSZip 2.5.0, pdfmake 0.1.32, DataTables 1.10.16, Editor 1.6.5, AutoFill 2.2.2, Buttons 1.4.2, Column visibility 1.4.2, Flash export 1.4.2, HTML5 export 1.4.2, Print view 1.4.2, ColReorder 1.4.1, FixedColumns 3.2.3, FixedHeader 3.1.3, KeyTable 2.3.2, Responsive 2.2.0, RowGroup 1.0.2, RowReorder 1.2.3, Scroller 1.4.3, Select 1.2.3

Hidden custom form template not showing up

$
0
0

Hello I have a custom editor form template from one of the examples as below

<div id="customForm" style="display:none">
    <fieldset class="name">
        <legend>Name</legend>
    </fieldset>
    <fieldset class="office">
        <legend>Office</legend>
    </fieldset>
    <fieldset class="hr">
        <legend>HR info</legend>
    </fieldset>
</div>

the only thing is by default its hidden
and I am trying to show/hide it as below.. but the template is not showing up.. when I manually do the $(#customForm).show() from developer tools it show up correctly..

    editor = new $.fn.dataTable.Editor( {
        ajax: base_url + 'api/voucher',
        table: "#voucher",
        template: "#customForm",
        idSrc:  'voucher_id',
        fields: [{
               label : "Voucher",
               name : "voucher_id",
               type: "hidden"
           },
               {
                   label : "Voucher Type",
                   name : "voucher_type",
                   type: "select2",
               ipOpts : [
                  {'label' : 'Credit', 'value' : 'Credit'},
                  {'label' : 'Debit', 'value' : 'Debit'}
               ],
                   opts: {
                   "placeholder": "Select Voucher Type",
                   "allowClear": true
                }
               },
               {
                label: "Credit Party",
                name: "credit_party_id",
                type: "select2",
                ipOpts: getFirmList('credit_party_id'),
                opts: {
                   "placeholder": "Select Credit Party",
                   "allowClear": true
                }
            },
            {
                    label: "Debit Party",
                    name: "debit_party_id",
                        type: "select2",
                        ipOpts: getPartyList('debit_party_id'),
                 opts: {
                    "placeholder": "Select Debit Party",
                    "allowClear": true
                    }
            },
            {
                    label: "Voucher Amount",
                    name : "voucher_amount"
            },
            {
                    label: "Narration",
                    name: "narration"
            },
            {
                    label: "Status",
                    name: "status",
                    type: "todo",
                    def: 1
            }
        ]
    });

    editor.on('initEdit', function() {
        $("#customForm").show();
    });

    editor.on('postEdit', function() {
        $("#customForm").hide();
    });
    editor.on('initCreate', function() {
        $("#customForm").show();
    });

    editor.on('postCreate', function() {
        $("#customForm").hide();
    });

Any suggestions would be really appriciated.

File upload always fails

$
0
0

Hi
I am trying to upload an image from editor form as below

            {
                label: "Image:",
                name: "image",
                type: "upload",
                display: function ( id ) {
                    console.log(id);
                    return '<img src="'+ base_url +'/web/uploads/temp/'+ id +'"/>';
                },
                noImageText: 'No image'
            }

I have confirmed that the file is getting uploaded successfully with response from server as below..

{"data":{"upload":{"id":"4872f7a766e4cb216b194bc7d185c758.png"}}}

but somehow, the console.log in display function is not happening.. that means the display function is not getting executed...

Can u please help me with this ??

Also, I want the user to be able to upload the image both while creating and updating a record ..
so is there a way to pass the record ID when uploading an image .. maybe 0 for new and ID for editng the image ??

Regards
Kaustubh

Remove Rows Before Table Init

$
0
0

I'm storing some data on the client (localStorage) that contains a list of ids that should be excluded from the table on initialization. I don't have the ids server-side, so this has to happen on the client. I thought this would be simple by using the rowCallback, but I can't seem to figure out how to remove the row if it's in my list of excludes. Here's my best attempt so far. I don't get any errors, just nothing happens and the rows are still there:

rowCallback: function( row, data, index ) {
  if ( aScanCult.indexOf(data[1]) > -1 ) row.remove();
}

Surely this can be done before the table builds rather than after it's all ready, right?

How to re-bind filter dropdown after filter table against another dropdown

$
0
0

Hello,

I have to make my HTML table fully supported with multi-level filtration.

In the attachment, we have dropdowns related to each column, my problem is How to update the values of rest of dropdown list, if I am using a column's drop-down to filter my table.

Like here if I am filtering AccountNumber- with a value 2003131352 Then the Service-type column's filter dropdown should not contain electric.

Please help me. Sorry, my English is poor.

Enable inline for one column only

$
0
0

Hi,

Is there any easy way to enable inline editing for only one column?

I have about 7 columns and one of them is a status select dropdown, for which it should be possible to update very quickly/inline.

Thanks and merry xmas :)


TypeError: f[b] is not a function when clicking Update, New, Delete button

$
0
0

The table renders and displays the data yet, when trying to edit, delete, or add a new record, I get error:
TypeError: f[b] is not a function

Here is the debug:
http://debug.datatables.net/alujin

Here is the code:

var editor; // use a global for the submit and return data rendering in the examples

$(document).ready(function () {

       editor = new $.fn.dataTable.Editor({
            ajax: "/api/StudentImmigrationNotesDT",
            model: "StudentImmigrationNotesModel",
            table: "#ImmigrationNotes",
            fields: [{
                    label: "Advised Date:",
                    name: "imnAdvisingDate",
                    type: "datetime"
            }, {
                    label: "Action Given:",
                    name: "imnAdvisingAction",
            }, {
                    label: "Advise Type:",
                    name: "imnAdvisingType",
           }, {
                    label: "Note:",
                    name: "imnAdvisingNote",
            }, {
                label: "Source:",
                name: "imnAdvisingSource",
           }, {
               label: "School ID:",
               name: "imnSchoolMasterID",
            }, {
                label: "Student ID:",
                name: "imnStudentUserID",
           }, {
               label: "Advise ID:",
               name: "imnImmigrationNoteID",
           }
            ]
        });

        // setup and establish the DataTable
        $("#ImmigrationNotes").DataTable({
            ajax: "/api/StudentImmigrationNotesDT",
            model: "StudentImmigrationNotesModel",
            // the columns used
            //data: data,
            columns: [
                { data: 'Advised Date' },
                { data: 'Action Given' },
                { data: 'Advise Type' },
                { data: 'Advise Note' },
                { data: 'Advise Source' },
                { data: 'School ID' },
                { data: 'Student ID' },
                { data: 'Advise ID' }
            ],
            // this sets the feedback text
            "oLanguage": {
                //"sUrl": "media/language/de_DE.txt",
                "sZeroRecords": "No records match your search criterion.",
                "sLengthMenu": "Display _MENU_ records per page.",
                "sInfo": "Displaying _START_ to _END_ of _TOTAL_ records.",
                "sInfoEmpty": "Showing 0 to 0 of 0 records.",
                "sInfoFiltered": "(Filtered from _MAX_ total records.)"
            },
            // this is for the copy, export to Excel, Print and PDF
            //dom: '<"top"fil<"toolbar">p>rt<"bottom"Bil>',
            dom: '<"top"r<"toolbar">fl>rt<"bottom"Bpi>',
            buttons: [
                {
                    extend: 'copyHtml5',
                    //ButtonText: 'Copy Page',
                    exportOptions: {
                        rows: ':visible',
                        columns: ':visible'
                    },
                },
                {
                    extend: 'csvHtml5',
                    //ButtonText: "Export to CSV",
                    exportOptions: {
                        rows: ':visible',
                        columns: ':visible'
                    },

                },
                {
                    extend: 'excelHtml5',
                    //ButtonText: "Export to CSV",
                    exportOptions: {
                        rows: ':visible',
                        columns: ':visible'
                    },
                },
                {
                    extend: 'pdfHtml5',
                    //ButtonText: "PDF",
                    exportOptions: {
                        rows: ':visible',
                        columns: ':visible'
                    },
                },
                {
                    extend: 'print',
                    //ButtonText: "Print",
                    exportOptions: {
                        rows: ':visible',
                        columns: ':visible'
                    },
                },
                //'selectedSingle',
                'selectAll',
                'selectNone',
                //'selectRows',
                //'selectColumns',
                //'selectCells',

                //// this hides or shows columns
                //{
                //    extend: 'collection',
                //    text: 'Toggle Visibility',
                //    buttons: [
                //        {
                //            text: 'Recalled',
                //            action: function (e, dt, node, config) {
                //                dt.column(6).visible(!dt.column(6).visible());
                //            }
                //        },
                //        {
                //            text: 'Action',
                //            action: function (e, dt, node, config) {
                //                dt.column(7).visible(!dt.column(7).visible());
                //            }
                //        }
                //    ]
                //},

                { extend: "create", editor: editor },
                { extend: "edit", editor: editor },
                { extend: "remove", editor: editor }

            ],

            // default settings
            keys: false, // single cell select if true
            info: true,
            sort: true,
            searching: true,
            select: true,
            ordering: true,
            order: [[0, 'desc']],
            scrollY: '50vh',
            scrollX: true,
            scrollCollapse: true,
            bJQueryUI: true,
            sPaginationType: "full_numbers",
            displayStart: 0,
            stateSave: true,
            autoWidth: true,
            paging: true,
            fixedHeader: true,
            fixedColumns: false,
            columnReorder: true,
            serverSide: false,
            processing: true,
            deferRender: true,
            responsive: true,

            //columnDefs: [
            //             { width: '20%', targets: 0 }
            //            ],
            lengthMenu: [[1, 5, 10, 25, 50, 100, -1], [1, 5, 10, 25, 50, 100, "All"]],
            iCookieDuration: 60 * 60 * 24, // 1 day keep cookie
        });

how to complete checkbox with JSON from PHP?

$
0
0

Hi!!
I make the checkbox adding this code in columnDefs.

{
'targets': 7,
 'searchable':false,
 'orderable':false,
 'className': 'dt-body-center',
 'render': function (data, type, full, meta){
         return '<input type="checkbox" name="id[]" value="'   + $('<div/>').text(data).html() + '">';

    }
}

Now I try complete the checkbox with data from PHP in JSON. In console I can see that parametre 'full' contains all de data but I can´t manipulate it. I need to compare what is the value of JSON for mark each checkbox.

Sorry for my english and I waitting for a response :)

Error importing sqlite.sql

$
0
0

Hi there,

I have created a database test.sqlite3 in DB Browser for SQLite, then I tried to import file sqlite.sql that comes with the downloadable package Editor-PHP.1.7.0.zip. I get the following error:

Error importing data: Error in statement #23: not an error. Aborting execution and rolling back.

Do you know what is causing this error or what I should do to fix it? Thanks.

Cheers, Manuel

Bug when using "paging: false" together with KeyTable

$
0
0

Hello,

With disabled paging, but enabled KeyTable, DataTables should not try to paginate when pressing the page up/down keys. Instead the browser should scroll. Otherwise it just shows less entries ("Showing 41 to 48 of 48 entries") without giving the user the chance to switch to another page.

DataTables: Read mulitidimensional array multidimensional?

$
0
0

I have multiple datas which I all send via json_encode() from PHP to JavaScript. And because there are so many dates I pack them with arrays. At the end I have this JSON return:

[
    [
        {
            "daten": [
                "1",
                "2",
                "3",
                "4",
                "5",
                "6",
                "7",
                "8",
                "9",
                "10",
                "11",
                "12",
                "13",
                "14",
                "15",
                "16",
                "17",
                "18",
                "19",
                "20",
                "21",
                "22"
            ]
        },
        {
            "anzahl": [
                "1",
                "0",
                "0",
                "0",
                "0",
                "1",
                "0",
                "0",
                "0",
                "0",
                "0",
                "0",
                "0",
                "0",
                "1",
                "0",
                "0",
                "0",
                "0",
                "1",
                "1",
                "2"
            ]
        }
    ],
    [
        {
            "datum": [
                "01.12.2017",
                "06.12.2017",
                "20.12.2017",
                "21.12.2017",
                "22.12.2017",
                "22.12.2017"
            ]
        },
        {
            "link": [
                "https:\/\/radlvoo.de\/blog\/produkt\/diamant-elan-super-legere-h-2017-rh-groesse-60\/",
                "https:\/\/radlvoo.de\/blog\/produkt\/diamant-topas-villiger-s-2017-rh-groesse-53-2\/",
                "https:\/\/radlvoo.de\/blog\/produkt\/haibike-seet-hardfour-life-1-0-2017-rh-groesse-30\/",
                "https:\/\/radlvoo.de\/blog\/produkt\/bergamont-e-ville-xt-wave-2017-rh-groesse-56\/",
                "https:\/\/radlvoo.de\/blog\/produkt\/diamant-achat-esprit-dt-t-2017-rh-groesse-45\/",
                "https:\/\/radlvoo.de\/blog\/produkt\/scool-chix-pro-26-7-2016\/"
            ]
        },
        {
            "kategorie": [
                "TREKKINGR\u00c4DER",
                "CRUISER \/ RETRO",
                "KINDER- \/ JUGENDFAHRR\u00c4DER",
                "E-BIKES",
                "E-BIKES",
                "KINDER- \/ JUGENDFAHRR\u00c4DER"
            ]
        },
        {
            "count": [
                "2",
                "1",
                "1",
                "1",
                "1",
                "1"
            ]
        }
    ]
]

I do access those arrays like this:

var tmp = JSON.parse(result);
console.log("Daten: " + tmp[0][0].daten + " | Anzahl: " + tmp[0][1].anzahl + " | Daten: " + tmp[1][0].datum + "Anzahl: " + tmp[1][3].anzahl);

My problem right now is that DataTables always throws a error:

Uncaught SyntaxError: Unexpected token o in JSON at position 1
    at JSON.parse (<anonymous>)
    at dataSrc ((index):1096)
    at jquery.dataTables.min.js:18
    at ta (jquery.dataTables.min.js:40)
    at jquery.dataTables.min.js:48
    at i (jquery.dataTables.min.js:35)
    at Object.success (jquery.dataTables.min.js:35)
    at i (jquery.js:2)
    at Object.fireWith [as resolveWith] (jquery.js:2)
    at y (jquery.js:4)

There you can find this:
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]

This is how my dataTables function looks like:

var contactsTable = function() {
          jQuery('#databaseTable').DataTable({
              serverSide: false,
              ajax: {
                  'url': (" /requestLeadClicksController.php?" + jQuery('#formToRequestLeadClicks').serialize()),
                  'type': 'GET',
                  dataSrc: function (json) {
                     json = JSON.parse(json);
                     return json.data;
                  },
              },
              iDisplayLength: 10,
              columns: [
                  { data: 'datum' },
                  { data: 'link' },
                  { data: 'kategorie' },
                  { data: 'count' }
              ],
          });
        };

        contactsTable();

That means, all comes down to the fact that DataTables cannot read the arrays inside the arrays. As you can see I already tried to parse them with JSON.parse()... How can I access my arrays?

Each index belongs to the same index on the result[1][0].datum, result[1][1].link, result[1][2].kategorie and result[1][3].count.

That means, row one in the table should look like this:

01.12.2017 - https:\/\/radlvoo.de\/blog\/produkt\/diamant-elan-super-legere-h-2017-rh-groesse-60\/ - TREKKINGR\u00c4DER - 2

Where is the problem? How can I fix the access array problem?

Kind regards

Viewing all 81798 articles
Browse latest View live


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