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

Possible bug using ColVis and stateSave (with save and load Ajax call) together

$
0
0

Hello DataTables,

I'm seriously impressed with DataTables and all of it's options. Never have I seen a library on datatables so complete and extendable. Loving it!

The reasing I'm posting is because i'm running into a problem that I can't solve, despite hours of debugging. I'm using the ColVis extension and the saveState stateSaveDT functionality. If the saveState functionality uses the local storage (HTML5) the ColVis extension works perfectly without problems. But when I use the stateSaveCallback stateSaveCallbackDT and stateLoadCallback stateLoadCallbackDT to save and load the state server-side into the database something weird happens with the ColVis extension. The state is loaded and saved correctly into the database with Ajax calls but if a make a column visible again after hiding it it will position the header th correctly but will position the corresponding td of each row at the end of the row in stead of the correct position. Also the saved visibility of a column is not restored when using the saveState functionality.

I've tried using the latest stable versions and the latest nightly builds, but nothing seems to work. Can you please help me?

<script language="javascript">
    $(document).ready(function() {
        var owoningbeheerwoningendatatable = $('#woningbeheerwoningendatatable').DataTable( {
            'dom': "RC<'clear'><'row'<'col-xs-12 col-sm-6 col-md-6 col-lg-6'Tl>r>t<'row'<'col-xs-3 col-sm-4 col-md-5'i><'col-xs-9 col-sm-8 col-md-7 text-right'p>>",
            'processing': true,
            'serverSide': true,
            'responsive': true,
            'stateSave': true,
            'ajax': {
                'url': '/woningbeheer/datatables/woningenjson'
            },
            'lengthMenu': [ [ 10, 25, 50, 75, 100, 250, 500, -1 ], [ 10, 25, 50, 75, 100, 250, 500, 'Alles' ] ],
            'order': [ [ 1, 'asc' ] ],
            'colVis': {
                'buttonText': 'Toon / verberg kolommen',
                'overlayFade': 0,
                'exclude': [ 0 ]
            },
            'stateSaveCallback': function (settings, data) {
                $.ajax({
                    'url': '/datatables/state/save',
                    'data': { 'identifier': 'woningbeheerwoningendatatable', 'data': data },
                    'dataType': 'json',
                    'method': 'POST'
                });
            },
            'stateLoadCallback': function (settings) {
                var o;
                $.ajax({
                    'url': '/datatables/state/load',
                    'data': { 'identifier': 'woningbeheerwoningendatatable' },
                    'async': false,
                    'dataType': 'json',
                    'method': 'POST',
                    'success': function (json) {
                        o = json;
                    }
                });
                return o;
            },
            'stateSaveParams': function (settings, data) {
                for (var i = 0; i < data.columns.length; i++) {
                    data.columns[i].search.search = '';
                }
                data.search.search = '';
            },
            'tableTools': {
                'sSwfPath': '/metronics/global/swf/copy_cvs_xls_pdf.swf',
                'aButtons': []
            },
            'columns': [
                {
                    'name': 'complexnummer',
                    'title': 'Complex',
                    'className': 'string complexnummer tooltips',
                    'tooltip': 'Het complexnummer van desbetreffende woning.',
                    'type': 'string',
                    'orderable': true,
                    'searchable': true,
                    'visible': true,
                    'data': {
                        'select': 'complex.complexnummer',
                        '_': 'complexnummer',
                        'filter': 'complexnummer',
                        'display': 'complexnummer'
                    },
                },
                {
                    'name': 'vhe_nummer',
                    'title': 'VHE',
                    'className': 'string vhe_nummer tooltips',
                    'tooltip': 'Het VHE nummer van desbetreffende woning.',
                    'type': 'string',
                    'orderable': true,
                    'searchable': true,
                    'visible': false,
                    'data': {
                        'select': 'woning.vhe_nummer',
                        '_': 'vhe_nummer',
                        'filter': 'vhe_nummer',
                        'display': 'vhe_nummer'
                    },
                },
                {
                    'name': 'straat',
                    'title': 'Straat',
                    'className': 'string straat tooltips',
                    'tooltip': 'De straatnaam van de woning.',
                    'type': 'string',
                    'orderable': true,
                    'searchable': true,
                    'visible': true,
                    'data': {
                        'select': 'woning.straat',
                        '_': 'straat',
                        'filter': 'straat',
                        'display': 'straat'
                    },
                },
                {
                    'name': 'huisnummer',
                    'title': 'Huisnr',
                    'className': 'integer huisnummer tooltips',
                    'tooltip': 'Het huisnummer van desbetreffende woning.',
                    'type': 'integer',
                    'orderable': true,
                    'searchable': true,
                    'visible': true,
                    'data': {
                        'select': 'woning.huisnummer',
                        '_': 'huisnummer',
                        'filter': 'huisnummer',
                        'display': 'huisnummer'
                    },
                },
                {
                    'name': 'toevoeging',
                    'title': 'Toev',
                    'className': 'string toevoeging tooltips',
                    'tooltip': 'De toevoeging aan het huisnummer van het adres van desbetreffende woning.',
                    'type': 'string',
                    'orderable': true,
                    'searchable': true,
                    'visible': true,
                    'data': {
                        'select': 'woning.toevoeging',
                        '_': 'toevoeging',
                        'filter': 'toevoeging',
                        'display': 'toevoeging'
                    },
                },
                {
                    'name': 'postcode',
                    'title': 'Postcode',
                    'className': 'string postcode tooltips',
                    'tooltip': 'De postcode van het adres.',
                    'type': 'string',
                    'orderable': true,
                    'searchable': true,
                    'visible': true,
                    'data': {
                        'select': 'woning.postcode',
                        '_': 'postcode',
                        'filter': 'postcode',
                        'display': 'postcode'
                    },
                }
            ]
        });

    });
</script>

Format a string in the format "price"

$
0
0

Hello everyone, having an unsigned integer, you can specify an option as rendering composed differently?

I would like to obtain, for example, the number 1.234,00

Currently I can only set an option.

Thank you for your help and I hope will be useful to other users.

Putting a button with a javascript function and parameters in an Ajax datatable

$
0
0

Hi,

This ajax data structure that includes a <button> to call a function and pass some parameters does not seem to work:

{ "data": [ [ "<button class='btn' onclick='myfunction(\"1\", \"test\");'>", "test, test" ] ] }

Can this be done? The table does not render. Remove the button, and it does.

Also, if I wanted to call my function for a particular row, how can swap in the values for the actual fields so that they are correctly passed? I tried looking at the API guide but there is only an example that shows a single item for an entire row. I need multiple buttons to pass data. Any pointers appreciated.

Is there a leave field event or field on blur?

$
0
0

Right now my code looks like this:

$( 'input', editor.field('account_name').node() ).on( 'click', function () {

But instead of a click i'd like the event to be when i finish editing the field above "account name".

Is there a way to accomplish this?

Newbie to datatables... Refresh option for table grid using server side pagination

$
0
0

Is there an option to refresh the data in the grid in the following server side pagination scenario:

The grid data is from a server side file that has many rows/records (over million)... the table grid display lets says 20 rows.

if by chance someone on the server side changes the contents of one of the records currently being displayed in the gird. it would be nice to have a refresh option (button) to refresh the current data in the grid. in all likely hood the user would not be aware that a update has taken place, but if there was a refresh option, it would show the current data.

Just a thought. If this option is available i apologize for not seeing it.

Thanks in advance.

Child rows contained in a subtable are not sortable

$
0
0

I have an application that requires the detail rows to be another DataTable with support for column sorting and filtering. Initially this was implemented with the 1.9.4 of datatables but I could not get the sorting of the subtable to work. I've tried upgrading to 1.10.4 but the sorting still doesn't work.

Config for the subtable is:

{ "data": "movieSeries", "order": [[0, "asc"]], "columns": [ {"title": "Title", "data": "title"}, {"title": "Date Published", "data": "date"}, {"title": "# of Pages", "data": "pages"}, {"title": "Movie Release Year", "data": "movieReleaseYr"} ] }

Data is:

    {
        "series": "Harry Potter",
        "books": [
        {
            "title": "Harry Potter and the Philosopher's Stone",
            "date": "6/1997",
            "pages": "309",
            "movieReleaseYr": "2001"
        },
        {
            "title": "Harry Potter and the Chamber of Secrets",
            "date": "7/1998",
            "pages": "341",
            "movieReleaseYr":"2002"
        }
     }

Subtable is rendered by when a click handler for tr fires. Click handler calls oTable.fnOpen(row, html, htmlClass). HTML for the subtable is below.

Title Date Published # of Pages Movie Release Year
Harry Potter and the Chamber of Secrets 7/1998 341 2002
Harry Potter and the Deathly Hollows 7/2007 652 2010, 2011
Harry Potter and the Goblet of Fire 8/2000 734 2005
Harry Potter and the Half-Blood Prince 7/2005 652 2009
Harry Potter and the Order of the Phoenix 6/2003 870 2007
Harry Potter and the Philosopher's Stone 6/1997 309 2001
Harry Potter and the Prisoner of Azkaban 8/1999 435 2004

But when I look at the event listeners in the chrome web console, the <th> rows do not have a click handler for th.sorting.

Uncaught RangeError: Maximum call stack size exceeded when calling fnGetData()

$
0
0

Hi, I am trying to download a large table (16 columns by >130k rows) containing numerical and string values as a .csv file. I tried using the table tools extension but as this just downloaded zero byte csv I tried doing it myself by getting all the rows of the table via fnGetData. This works fine and dandy with relatively small tables. When the size of the table increases over a certain size the above mentioned error occurs. The call stack:

Uncaught RangeError: Maximum call stack size exceeded jquery.dataTables.min.js:formatted:1702
q jquery.dataTables.min.js:formatted:1725 q.flatten jquery.dataTables.min.js:formatted:2469 (anonymous function) jquery.dataTables.min.js:formatted:1782 q.extend.g jquery.dataTables.min.js:formatted:1465 p.fnGetData test.html:377 outputRows test.html:339 (anonymous function) jquery.min.js:3 n.event.dispatch jquery.min.js:3 n.event.add.r.handle

I am using datatable version 1.10.2, jquery version 2.1.1, jquery ui version 1.11.2 and datatables.bootstrap.

Sure I could just recalculate the table data but this seems totally unnecessary. Maybe one of you can tell me why this simple operation causes this error. I do not have any control over server side settings and have to do all the calculation and download operations client-side.

Thanks Robert

My code works locally but once I upload to my remote server I am getting datatables/tn/7 error

$
0
0

I had to change the directory locations for the php files I edited the varies include lines in several files

I am able to get it to work locally but when I upload to my remote server I am getting a

DataTables warning

datatables/tn/7

I am confused why this would work locally but not on the remote server

Thanks for your help


Upgrade to 1.10 and migrate to Bootstrap

$
0
0

So my current implementation uses DataTables 1.9.4 and a custom jQuery UI theme.

I read this article: http://www.datatables.net/upgrade/1.10 which says that my functions should still work due to the maintained backwards-compatibility, which is great news! Is there a compelling reason to switch over to the new notation on a short timeline, or can I let it languish for a while?

I'm also considering switching to Bootstrap. Currently I do SOME manual jQuery UI CSS classing via callback functions (returning a row containing some jQuery UI widgets, etc), but other than that, how cumbersome should the change be?

I'm asking in advance rather than "just trying it" because my employers would rather my time not be spent on a weeks-long project, but I suspect that upgrading to 1.10 and switching to Bootstrap should take maybe 3 days tops. Anybody have a supporting or contradicting perspective on that timeline?

Thanks!

Uncaught TypeError: Cannot read property 'id' of null

$
0
0

I am evaluating Editor for testing REST API to make 'create', 'edit' and 'remove' work in my environment. Create works (with an infinite pause at the end however), but both edit and remove cause the error. How can I specify id in my JS so that dataTables handles it properly behind the scene?

    var editor = new $.fn.dataTable.Editor( {
        table: '#users',
        fields: [
            //{ label: 'id',  name: 'id'  },
            //{ label: 'Username',  name: 'username'  },
        ],
        ajax: {
            create: {
                type: 'POST',
                url: '/Controller/users.json'
            },
            edit: {
                type: 'PUT',
                url: '/Controller/users/_id_.json'
            },
            remove: {
                type: 'DELETE',
                url: '/Controller/users/_id_.json'
            }
        }
    } );
    var table = $('#Group').DataTable( {
        ajax: {
            "url" : "/Controller/users/dt_list.json",
        },
        dom: 'Tfrtip',
        columns: [
            { data : 'id'},
            { data : 'username'},
        ],
        tableTools: {
            sRowSelect: "os",
            aButtons: [
                { sExtends: 'editor_create',  editor: editor },
                { sExtends: 'editor_edit',    editor: editor },
                { sExtends: 'editor_remove',  editor: editor },
            ]
        }
    });

Column Filter doesn't work with hyperlink?

$
0
0

In my datatable, I am using columnFilter add-on and first column (ID) data has hyperlink. Hyperlink navigates to expected page but filter for this particular column (ID) doesnt't work. Any help is much appreciated. Below is my code

    <script>

        var dataSetString = $('#hiddenData').attr('value');
        var dataSet = eval(dataSetString);

        $(document).ready(function() {

           var table = $('#example').dataTable( {

                "data": dataSet,
                "aoColumns": [
                            { "title": "Id"},
                            { "title": "Issue Date" },
                            { "title": "Expiry Date" },
                            { "title": "Area" }
                ],
                "columnDefs": [
                               //title column has hyperlinks
                               {
                                   "render": function ( data, type, row ) {
                                       return '<a href="#{request.contextPath}/module/misc/module/search/titleDetails.jsf?titleId=' + data + '"><i class="fa fa-external-link"></i> ' + data + '</a>' ;
                                   },
                                   "targets": 0
                               }
                ],
                "order": [[ 0, "desc" ]]
            } );

            table.columnFilter({ sPlaceHolder: "head:before",
                aoColumns: [ {type: "number"},
                             {type: "number"},
                             {type: "number"},
                             {type: "number"}


                           ]

            });

        } );

    </script>

Next putton in pagination is not taking user past page 2

$
0
0

Hello. I've upgraded to DataTables-1.10.4. I noticed Next button for pagination for my AJAX tables was not working. My pagination is setup for 50 records per page. When I clicked the Next button on page 1, the 'Showing ...' message was changed to:

Showing 0,501 to 173 of 173 entries

Subsequent click of Next button would not do anything. All other buttons for pagination seem to work.

I tracked the issue to _fnPageChange method of jquery.dataTables.js (roughly line 3471). This is the original code:

    var
        start     = settings._iDisplayStart,
        len       = settings._iDisplayLength,
        records   = settings.fnRecordsDisplay();

I changed it to:

    var
        start     = parseInt(settings._iDisplayStart),
        len       = parseInt(settings._iDisplayLength),
        records   = settings.fnRecordsDisplay();

After adding parseInt() for start and len, the Next button pagination works.

Hopfully this will help someone else.

Thanks

Tom

Change column name for date range while exporting pdf or xls

$
0
0

Using Datatables with columnFilter and TableTools plugin. Table has date ranges as filters. While exporting to pdf the column name is "Expiry Date: From {from} to {to}", which doesnt look good in the report. Is there any way I can change this column name while exporting to pdf or xls. Below is my code.

            //create new table
            var table = $('#theListTable').dataTable( {
                "dom": 'T<"clear">lfrtip',
                "tableTools": {
                    "sSwfPath": "../swf/copy_csv_xls_pdf.swf",
                    "aButtons": [
                                 {
                                     "sExtends": "xls",
                                     "sButtonText": "#{searchMsg['lbl.exportToExcel']}",
                                     "oSelectorOpts": { filter: 'applied', order: 'current' }
                                 },
                                 {
                                     "sExtends": "pdf",
                                     "sButtonText": "#{searchMsg['lbl.exportToPdf']}",
                                     "oSelectorOpts": { filter: 'applied', order: 'current' }
                                 }
                            ]
                },
                    "columns": [
                        { "title": "#{searchMsg['lbl.eventId']}" },
                        { "title": "#{searchMsg['lbl.eventDate']}" },
                    ]
                } )
                .columnFilter({ sPlaceHolder: "head:after",
                    aoColumns: [ {sType: "number"},
                                 {type: "date-range", sRangeFormat: "#{searchMsg['lbl.eventDate']}" },
                                ]

                });

Column names appers in xls or pdf as below: Event Number Event Date: From {from} to {to}

Search/filter table before load

$
0
0

I'm using the following to render my table and it works fine:

`$(document).ready(function() { $("#occupations_datatable").DataTable({

"ajax": { "url":"occupations.php", "type":"GET" } ,

"paging": true, "sDom": '<"top">t<"bottom"><"clear">', "pageLength": 50, "order": [[ 1, "desc" ]],

"aoColumns": [ { "bSortable": true, "width": "40%", "sClass": "lang_body_2", "sTitle": "", "visible":false }, { "bSortable": true, "width": "40%", "sClass": "lang_body_2", "sTitle": "" }, { "bSortable": true, "width": "20%", "sClass": "lang_body_2", "sTitle": "Database"}, { "bSortable": true, "width": "20%","sClass": "lang_body_2","sTitle": "National Average" }, { "bSortable": true, "width": "20%","sClass": "lang_body_2 index_num table_index","sTitle": "Index" },

], });

});`

Here's my question...what can I add to this so that the table only renders rows with a certain string in column 0 (the one set to visible:false)? I've tried a bunch of things, but can't figure out how to search/filter before the table loads. I can figure out how to do it on, say, a button click, but I want to search/filter before the table is even rendered. Any help would be appreciated.

Thanks, JMR

How to get the jQuery UI ThemeRoller example working

$
0
0

The "jQuery UI ThemeRoller" example at the URL below works nearly perfectly. The only quirk I see is that in Chrome 39 and IE 11, the drop shadow effect for the row sort icons is somewhat broken. (I did not test any other browsers.)

http://www.datatables.net/examples/styling/jqueryUI.html

I wanted to reproduce that same example on my PC, so I downloaded DataTables 1.10.4, and opened the jQueryUI.html example (DataTables-1.10.4\examples\styling\jqueryUI.html). However, under these conditions, the page is essentially unstyled. All backgrounds are white, buttons are plain text without any space between them, icons and gradient images are missing, etc.

As a workaround, I tried downloading the working example to my PC using File > Save As. This brought much improvement, but the icons and gradient images are still missing.

What am I missing, and how can I integrate it into this example on my PC? I would ideally like to know how to fix it in the examples directory from the DataTables 1.10.4 download.

Thank you!

P.S. After two days of use, I'm very impressed with DataTables. The documentation, features, and ease of use are far better than another popular table plugin for jQuery that I've been using.


Bubble Edit only allowing one update

$
0
0

I have one table this is happening on, and 3 tables where it works perfect.

When I click on a field to update with the basic bubble edit setup, It works fine for that field, however, subsequent fields will not allow me to edit.I have to refresh the page to be able to click a field and have the bubble pop up.

I have the exact same setup, save for the table names, on 3 other tables within the app that it works perfectly on.

It seems to be an issue with CKeditor, as I get an error in Developer tools about it:

ckeditor.js:316 Uncaught TypeError: Cannot read property 'getEditor' of undefined

editor.ckeditor.js:45 Uncaught TypeError: Cannot read property 'destroy' of undefined

Is it possible that bubble edit isn't compatible with tables that use CKeditor?

Do you know of a work around?

Can't get all row data

$
0
0

Hello! First i have to say, im new to data tables and javascript at all. And thats my first project i'm using it. How can i get all data from the table in an array? This is what i have tried:

oTable = $('#dataTable').DataTable(); getAllMarker(); var rows = oTable.rows().data();
alert(rows.length);

alert always return 0 but my table is populated with values. This is done in the getAllMarker() Method.

function getAllMarker(){

        $.ajax({
            type: "POST",
            url: "marker.php",

            //IMPORTANT: set marker_table depending on current markerobject
            data:{function:"getAllMarker" },
            dataType: 'json',
            success: function(s){
                console.log(s);
                oTable.clear();
                for(var i = 0; i < s.length; i++) {
                    var space = " ";

                    oTable.row.add([
                        s[i][0],
                        s[i][0], //id
                        s[i][1], //attribut
                        s[i][11], //rating
                        s[i][12], //comment
                        s[i][4], //latitude
                        s[i][5], //longitude
                        s[i][6], //street
                        s[i][7], //city
                        s[i][8], //zip
                        s[i][2], //creation_time
                        s[i][3], //update_time
                        s[i][9]+=space+=s[i][10], //creator
                    ]).draw();;

                } // End For
            },
            error: function(e){
                console.log(e.responseText);

            }
        });


    }

Hope anyone can help me.

dynamic column value calculation

$
0
0

I am pulling data from sql using ajax call. imagine im getting 2 columns back time and distance from DB, i would like to use these values to calculate speed by dividing distance by time. so at the end i'll have three columns two would be from DB and third would be their combination. is it possible to do so?

here is simple call to DB

table = $('#results').DataTable({ "ajax": { async: false, global: false, url: "../php/getResults.php", dataType: "json" }, "columns": [{ "data": "Time" }, { "data": "Distance" }, { "data": "Speed" //needs to be calculate using above two data inputs. }], "order": [ [2, 'asc'] ] });

Create two tables from same source, but different groups

$
0
0

I have a single data source and have a table with data for all 50 states. I'd like to divide this into two groups (first 25 states, second 25 states) so I can display the data in two side by side columns each with its own table.

Is there a way to group the states into two groups, one for each table? Ideally, they'd each have their own sorting, etc, but without data from the other group being included.

Thanks, JMR

IE11 & FixedColumn : unwanted horizontal scrolling

$
0
0

Hello everybody,

I got an issue on IE11 when using FixedColumns. When scrolling horizontally the datatable, left column is truncated. There is a little horizontal scrollbar showing up this first column :

            var datatable = that.$table.DataTable({
                    scrollX:            "100%",
                    scrollY:            $('#content').height() - 120,
                    scrollCollapse:     true,
                    autoWidth:          false,
                    paging:             false,
                    sort:               false,
                    info:               false,
                    filter:             false,
                    stripeClasses:      []
                });
                new $.fn.dataTable.FixedColumns(datatable, {
                    leftColumns:        1
                });

Chrome / Firefox : http://imgur.com/uo7rUZb IE11 : http://imgur.com/oYLeyfZ

Thanks in advance.

Viewing all 82234 articles
Browse latest View live


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