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

Unable to display buttons

$
0
0

Attempting to use the Buttons extension, and not able to display the buttons, as per the documentation.
I've tried each of the methods, yet they are not showing.
Can you review my js on http://live.datatables.net/sojeluju/1/
Help show me what I'm missing.

$(document).ready( function () {
var table = $('#example').DataTable({
"sPaginationType" : "full_numbers",
"ajax": "/examples/server_side/scripts/server_processing.php",
"processing" : true,
"serverSide" : true,
"fixedHeader" : true,
"lengthMenu" : [[10, 25, 50, 100, 200, -1],[10,25,50,100, 200, "All"]],
"pageLength" : 25,
"sScrollX" : "110%",
"sScrollY" : "600px",
"bScrollCollapse": true,
"columnDefs": [
{ "type": "signed-num", "targets": 3}
],
dom: 'Bfrtip',
buttons: ['copy','excel','print']
});

        $('#example tfoot th').each(function() {
           var title = $('#example thead th').eq($(this).index()).text();
           console.log(title);
           $(this).html('<input type="text" placeholder="Search ' + title + '"/>');
       });
       table.columns().every(function () {
           var datatableColumn = this;
           $(this.footer()).find('input').on('keyup change', function() {
               datatableColumn.search(this.value).draw();
           });
       });

} );

Thank you,
Allan


Does DataTables support entity framework?

$
0
0

Can I use entity framework to define the target table and to execute the database operation (insert, update, delete)?
Since I would like to record audit log through entity framework, DataTables cannot help me to achieve this purpose.
Any recommendation?

How to get row data of all checked rows in data tables

$
0
0

Hello ,

I am new to data tables.
My data table contains checkbox, but i am not able to get the row data of checked rows.

is there any event available to get checked rows directly by giving the data table ID .?

Please help me out in this

Thanks in advance
Rakesh

how to implement server side data table using node js and mysql

$
0
0

Already implemented client side data tables using node js and mysql.

how to place custom download image in palce of CSV button and how to disable hover functionality ?

$
0
0

i want to place custom download and mail sending image in place of CSV button and want to disable hover functionality?

multi selection filter using dropdown list in header of each column

DataTables with currencyFormatter.js sort failure.

$
0
0

Hi @ all,

With following script I get a DataTables with a sum footer. I format all floats with currencyFormatter.js Combined with HTML-Tag class .monney. This works great. When I click a table headerlink to sort the table. All floats chance to -NaN €.
Has anybody a clou why this is happen and how to solve this.

$(document).ready(function() {

    $.get('stock.csv', function(data) {
        // start the table
        var html = '<table id="example" class="table table-striped table-bordered dt-responsive nowrap" cellspacing="0" width="100%">';

        // split into lines
        var rows = data.split("\n");

        // parse lines
        j = 0;
        rows.forEach(function getvalues(ourrow) {
                if (j == 0) {
                    // start a table row
                    html += "<thead><tr>";
                    htmltfoot = "<tfoot><tr>";

                    // split line into columns
                    var columns = ourrow.split(";");

                    var arrayLength = columns.length;
                    for (var i = 0; i < arrayLength; i++) {
                        html += "<th><div>" + columns[i] + "</div></th>";
                        if (i == 0){
                                htmltfoot += "<th class=\"sum\">Total:</th>";
                            } else {
                                htmltfoot += "<th class=\"sum money\">Total:</th>";
                            }
                    }
                    // close row
                    html += "</tr></thead>";
                    htmltfoot += "</tr></tfoot></tbody>";
                    html += htmltfoot;
                    j++;
                } else {
                    // start a table row
                    html += "<tr>";

                    // split line into columns
                    var columns = ourrow.split(";");

                    var arrayLength = columns.length;
                    for (var i = 0; i < arrayLength; i++) {
                        if (i == 0) {
                            html += "<th>" + columns[i] + "</th>";
                        } else {
                            if (columns[i] == 0){
                                html += "<td>" + columns[i] + "</td>";
                            } else {
                                html += "<td class='money'>" + columns[i] + "</td>";
                            }
                        }
                    }
                    // close row
                    html += "</tr>";
                }
            })
            // close table
        html += "</tbody></table>";

        // insert into div
        $('#container').append(html);
        $('#example').DataTable({
            "paging": false,
            "footerCallback": function(row, data, start, end, display) {
                var api = this.api();
                nb_cols = api.columns().nodes().length;
                var j = 1;
                while (j < nb_cols) {
                    var pageTotal = api.column(j, { page: 'current'}).data().reduce(function(a, b) {
                            if (b > 0) {
                            sumAB = Number(a) + Number(b);
                            return sumAB.toFixed(2)
                            }
                            else{return Number(a).toFixed(2);}
                        }, 0);
                    // Update footer
                    $(api.column(j).footer()).html(pageTotal);
                    j++;
                }
                OSREC.CurrencyFormatter.formatAll(
                {
                    selector: '.money',
                    currency: 'EUR'
                });
            }
        });
    });
    // Code here end
});

Trying to create a yadcf filter for a column with images

$
0
0

I need to create a filter on a tipical columns created with images: each field is an image with this format:

<img src='http://lab.onclud.com/psm/blackcircle.png' class='notasg'>

I've created a fiddle example here.

An explication:
* there are only 2 diferents status: [assigned/not assigned] although there are 4 diferents images (black, red, yellow and green).
* Only black image correspond to not assigned status. The others three ones (red, yellow and green) correspond to assigned status.
* As you could see, I've tried to differentiate those status by class HTML tag in img elements (notasg/asgn).

Thanks in advance.


Can i use datatables inside Polymer component?

$
0
0

Hi All,
we are building an web application using angular + Polymer. we have a requirement to show table with add/edit/details/icons etc which are there in datatables.js. We have been using this in many other projects and we liked it more friendly in aspects of developement as well as rich User experience to end users.
My Question is can we use datatables inside polymer and build an component. I found while searching in google that current datatables implementation doesnt support Shadow DOM.
Is it true? if yes then when can we expect ploymer based datatables? if it is false can you please send us details of how we use it.
Or is this scope is out of scope for you guys?
Please let us know as we need this ASAP?

Height resizing of edit form not correct when using dependent()

$
0
0

When using the dependent() option with a lot of fields, the automatic height resizing of the edit form is not working properly, so the Update button is not at the bottom of the edit form any more but moves upwards overlapping the input fields area.
This only happens when while dependent fields showing there is a scrollbar due to the large number of fields and while dependent fields being hidden there are only a few fields left without scrollbar.
Is there any way to trigger the resizing after the dependent() routine has fired to adjust the form height properly? Or as an alternative to set a fixed form height which can handle both shown and hidden dependent fields?

Thanks, Denis

Editor Validation - Accept only dbValues available in another column

$
0
0

How exactly can I define that for 'column_04' (text input) only values available in column_02 (of the database column) ... or empty ('') are valid? Like this?

Editor::inst( $db, 'users' )
    ->field(
        Field::inst( 'users.column_01' ),
        Field::inst( 'users.column_02' ),
        Field::inst( 'users.column_03' ),
        Field::inst( 'users.column_04' )
            ->validator( 'Validate::dbValues', array(
                'field' => 'users.column_02'
                'valid' => array(''),
                'message' => "Value does not exist!"
            ) )
    )
    ->process($_POST)
    ->json();

I'm not exactly sure https://editor.datatables.net/manual/php/validation

System Error on Ajax Response

$
0
0

Hi,

I’m a licenced user and have been implementing DataTables and Editor for an internal project. I’ve prechecked the documentation / forums and can’t get my head around this issue.

I have a Editable datatable, which is loading JSON data successfully from the server.

JSON from server:

{
"data": [
{
"DT_RowId": "row_3",
"FUND_MANAGER": "Graham K4-D15 (Innocap Track)",
"NO_MULTI_MGR_OR_PORT_ALPHA": "ABC",
"PERCENT_SUBINVESTMENT_GRADE": "DEF",
"BENCHMARK_DRIVEN": "",
"MINIMU_SIZE": "",
"UCITS_III": "",
"TOTAL_ASSETS_FUND": "",
"SCORE": "",
"COMMENT": ""},
{
"DT_RowId": "row_1",
"FUND_MANAGER": "SPDR Gold Tracker",
"NO_MULTI_MGR_OR_PORT_ALPHA": "",
"PERCENT_SUBINVESTMENT_GRADE": "",
"BENCHMARK_DRIVEN": "",
"MINIMU_SIZE": "",
"UCITS_III": "",
"TOTAL_ASSETS_FUND": "",
"SCORE": "",
"COMMENT": ""},
{
"DT_RowId": "row_2",
"FUND_MANAGER": "Transtrend (Innocap Track)",
"NO_MULTI_MGR_OR_PORT_ALPHA": "",
"PERCENT_SUBINVESTMENT_GRADE": "",
"BENCHMARK_DRIVEN": "",
"MINIMU_SIZE": "",
"UCITS_III": "",
"TOTAL_ASSETS_FUND": "",
"SCORE": "",
"COMMENT": ""}
],
"options": [],
"files": []
}

On inline editing a cell value and then clicking out, the AJAX request is sent and the server returns the expected JSON but the rows are not being updated. Instead, I get an error message: ‘A system error has occurred (More information)’ under the field taking me to: https://datatables.net/manual/tech-notes/12.

JSON returned:
Have tried returning the above JSON (using the same URL for param ajax: under editor), as well as the following:

{
   "data":    [
        {
            "DT_RowId": "row_3",
            "FUND_MANAGER": "Graham K4-D15 (Innocap Track)",
            "NO_MULTI_MGR_OR_PORT_ALPHA": "ABC",
            "PERCENT_SUBINVESTMENT_GRADE": "DEF",
            "BENCHMARK_DRIVEN": "GEF",
            "MINIMU_SIZE": "",
            "UCITS_III": "",
            "TOTAL_ASSETS_FUND": "",
            "SCORE": "",
            "COMMENT": ""
        }
    ]
}
  • I have extracted the HTML and javascript from our page and can be viewed here: https://jsfiddle.net/zsaeed/39brvysm/4/#
  • This being an internal application is not accessible outside the site.
  • The response headers shown by the browser are correct too:
    Content-type: application/json
  • A thought, could it be a version issue with Jquery?

Kind regards

How to set the active state when a button is clicked in the "column groups" example?

$
0
0

I would like to set the active state when a button is clicked in the Column Groups example, and unset the active state for the other buttons. I have created a JSFiddle with my attempt to solve the problem. Unfortunately my code seems to toggle all the buttons, instead of only the one I click. If one button is clicked twice, the active state is deselected when it should remain selected.

Thanks

jquery datatables (bower) asp.net mvc 6 server side processing not working

$
0
0

I've tried this famous link (although written for mvc5) but it doesn't work in mvc 6. Please can anyone provide some instructions for doing the same as done in the link but in aspnet mvc 6? I get the following error when running the code provided for mvc5 in my mvc6 project:
Error Image

and the following javascript errors.
Error Image

Change title on PDF viewer

$
0
0

Hi everyone,

I want to do a small changes on my PDF viewer. I want to change the title on PDF. I noticed that the title on the PDF following title on the website, but how we can edit the title on the PDF viewer without change title in our website?

Can see on image below. Now the title is "Bikebulance Admin Panel". but I want to change the title to "Cash Sale"

Thank you!


Print the Table?

$
0
0

I have Two Question on Printing the tables.
1. How Change the title of table while on print.
2. How print the table with tfoot content.

Editor: unable to get the whole table content (filtered content works)

$
0
0

Hello,

I would like to know if there are some limitations or invalid characters in database text field that Editor does not support.

I ask for this because I try to get the whole content of a table and I get the following error message:
DataTables warning: table id=table-param-detail - Invalid JSON response. For more information about this error, please see http://datatables.net/tn/1

My table has only 990 lines and contains only two columns.
The primary key (VARCHAR 100)
A column with the value (LONG VARCHAR)

I supposed that the problem come from data in my table because if I add a filter (where clause) I can get the result (valid json in return) and the Datatables component works perfectly.

Thanks in advance and have a nice day.

Oracle - insert and edit problem on joined table

$
0
0

Hi all,

i have a problem with one of my tables. It has joined data on an oracle-db, when trying to edit a row or insert a new one.

Here are my codes:

PHP

<?php

/*
 * Editor server script for DB table STG_TAB_ARTIKEL
 * Created by http://editor.datatables.net/generator
 */

// DataTables PHP library and database connection
include( "lib/DataTables.php" );

// Alias Editor classes so they are easy to use
use
    DataTables\Editor,
    DataTables\Editor\Field,
    DataTables\Editor\Format,
    DataTables\Editor\Mjoin,
    DataTables\Editor\Options,
    DataTables\Editor\Upload,
    DataTables\Editor\Validate;


    // Build our Editor instance and process the data coming from _POST
    Editor::inst( $db, 'STG_TAB_ARTIKEL a', 'a.PK_ARTIKEL_ID' )
        ->debug(true)
        ->fields(
            Field::inst( 'a.ARTNR' )
                ->validator( 'Validate::unique' )
                ->validator( 'Validate::required' )
                ->validator( 'Validate::numeric' ),
            Field::inst( 'a.FK_STG_TAB_ARTKAT' )
                ->options( Options::inst()
                    ->table( 'STG_TAB_ARTIKELKATEGORIE' )
                    ->value( 'ARTKATNR' )
                    ->label( 'ARTKAT' )
                )
                ->validator( 'Validate::dbValues' ),
            Field::inst( 'a.ARTBEZ' )
                ->validator( 'Validate::notEmpty' ),
            Field::inst( 'a.ARTMAß' ),
            Field::inst( 'ak.ARTKAT' )
        )
        ->leftJoin( 'STG_TAB_ARTIKELKATEGORIE ak', 'ak.ARTKATNR', '=', 'a.FK_STG_TAB_ARTKAT')
        ->process( $_POST )
        ->json();

?>

JS

/*
 * Editor client script for DB table STG_TAB_KUNDEN
 * Created by http://editor.datatables.net/generator
 */

(function($){

$(document).ready(function() {
    var editor = new $.fn.dataTable.Editor( {
        ajax: 'sources/table.STG_TAB_ARTIKEL.php',
        table: '#STG_TAB_ARTIKEL',
        fields: [
            {
                "label": "Artikel:",
                "name": "a.ARTNR"

            },
            {
                "label": "Artikelkategorie:",
                "name": "a.FK_STG_TAB_ARTKAT",
                "type": "select",
                "placeholder" :  "Bitte Kategorie auswählen.."
            },
            {
                "label": "Bezeichnung:",
                "name": "a.ARTBEZ"
            },
            {
                "label": "Maße:",
                "name": "a.ARTMAß"
            }
        ]
    } );


    var table = $('#STG_TAB_ARTIKEL').DataTable( {
        dom: 'Bfrtip',
        ajax: 'sources/table.STG_TAB_ARTIKEL.php',
                serverSide: true,
        scrollY:        '70vh',
        scrollCollapse: true,
        paging:         false,
        cache: true,
        columns: [
            {
                "data": "a.ARTNR"
            },
            {
                "data": "ak.ARTKAT"
            },
            {
                "data": "a.ARTBEZ"
            },
            {
                "data": "a.ARTMAß"
            }
        ],
        select: "single",
        lengthChange: false,
        buttons: [
            { extend: 'create', editor: editor }
            ,{ extend: 'edit',   editor: editor }
        ]
    } );
} );

}(jQuery));

On debbuging the data-Header seems correct:

data[row_5760][a][ARTNR]:-2
data[row_5760][a][FK_STG_TAB_ARTKAT]:23
data[row_5760][a][ARTBEZ]:HTV - Einweg
data[row_5760][a][ARTMAß]:0x0

But on the debugSql-array on Preview Page doesn't start an update:
(see attachment) [2]query: SELECT a.PK_ARTIKEL_ID as "a.PK_ARTIKEL_ID", a.ARTNR as "a.ARTNR", a.FK_STG_TAB_ARTKAT as "a.FK_STG_TAB_ARTKAT", a.ARTBEZ as "a.ARTBEZ", a.ARTMAß as "a.ARTMAß", ak.ARTKAT as "ak.ARTKAT" FROM STG_TAB_ARTIKEL a LEFT JOIN STG_TAB_ARTIKELKATEGORIE ak ON ak.ARTKATNR = a.FK_STG_TAB_ARTKAT WHERE a.PK_ARTIKEL_ID = :where_0

Don't know why it isn't working, i have another table w/o the leftJoin() param which is working perfectly.

Looking forward to any help!
Thanks in advance

Br Toni

Editor (2)

$
0
0

I seem to have run into another wrinkle with the behaviour of the editor. I believe it is related to my previous post titled 'Editor'.

The problems is:
When using the bubble edit functionality I start at the first row(1) and the edit is properly recorded. The second row(2) also behaves as expected. If I then leave a gap after the second row(2) edit and edit another row(5) it behaves as expected. Now when I return to row(1) or any previously edited row the last edit I made(row 5) is presented in the edit dialogue and if I change it the last row(5) I edited is updated. If I then edit a row that has never been edited it works as expected in that the dialogue is presented with the cell data. The behaviour is the same when I use a checkbox, and an edit button and do the editing through a form.
When it misbehaves the data content that gets passed into the function is from the last edited console.log("the row ",t.row( this ).data()); while the row index console.log("the row ",t.row( this ).index()); is correct and does not match the data.

The site is still available at

https://tmtest.dlinkddns.com:10010
Sign In with
user - datatables
password - 1234

The Editor Definition

   editor = new $.fn.dataTable.Editor( {
        table: "#myTable",
        fields: [
            {type: "readonly", label: "depotName", name: "depotName" } ,
            {type: "readonly",label: "clientName", name: "clientName"},
            {type: "readonly",label: "rtuName", name: "rtuName"},
            {type: "readonly",label: "deviceName", name: "deviceName"},
            {type: "readonly",label: "serialNumber", name: "serialNumber"},
            {type: "readonly",label: "assetNumber", name: "assetNumber" },
            {label: "serviceTag", name: "serviceTag"},
            {type: "readonly",label: "location", name: "location" },
            {type: "readonly",label: "ipAddress", name: "ipAddress"},
            {type: "readonly",label: "deviceType", name: "deviceType"},
            {type: "readonly",label: "deviceStatusMessage", name: "deviceStatusMessage" },
            {type: "select", label: "quiesce", name: "quiesce", options: quiesceOpts },
            {type: "readonly",label: "utilization", name: "utilization" },
            {type: "readonly",label: "coverage", name: "coverage"},
            {type: "readonly",label: "monoLifeCount", name: "monoLifeCount" },
            {type: "readonly",label: "colorLifeCount", name: "colorLifeCount"},
            {type: "readonly",label: "pageCountThisMonth", name: "pageCountThisMonth"},
            {type: "readonly",label: "createdDate", name: "createdDate"},
            {type: "readonly",label: "lastActiveDate", name: "lastActiveDate" },
            {type: "readonly",label: "deviceId", name: "deviceId"}
        ],
        ajax: function ( method, url, d, successCallback, errorCallback ) {
            var output = { data: [] };
            if ( d.action === 'edit' ) {
                  // Update each edited item with the data submitted
                $.each( d.data, function (id, value) {
                   //console.log(findIndexInData(theTable.data, 'deviceId', id));
                   console.log("in edit -id ",id," -value ",value);
                   value.DT_RowId = id;
                   $.extend( todo, value );
                   console.log("todo after extend ",todo);
                   console.log("output before push ",output);
                   output.data.push( todo );
                } );
            }
             // Store the latest `todo` object for next reload
            localStorage.setItem( 'todo', JSON.stringify(todo) );
console.log("the final output ",output);
            // Show Editor what has changed
            successCallback( output );
        }
    } );

The table definition

var editor; // use a global for the submit and return data rendering in the examples
// make sure to modify the column formating info in the datatables init structures
function buildTable()
{
    // Create or update the todo localStorage entry
    if ( localStorage.getItem('todo') ) {
        todo = JSON.parse( localStorage.getItem('todo') );
    }


    // Activate an inline edit on click of a table cell
    $('#myTable').on( 'click', 'tbody td:not(:first-child)', function (e) {
        console.log("the row ",t.row( this ).data());
        console.log("the row ",t.row( this ).index());
        $.extend( todo, t.row( this ).data() );
        editor.bubble( this );
        console.log(t.row);
    } );

    console.log("table is new");
    var t = $('#myTable').DataTable( {
     "destroy": true,
       "data": theTable.data,
       "columns": [
            {"data": "depotName"}, {"data": "clientName"}, {"data": "rtuName"}, {"data": "deviceName"}, {"data": "serialNumber"}, {"data": "assetNumber"},
            {"data": "serviceTag"}, {"data": "location"}, {"data": "ipAddress"}, {"data": "deviceType"}, {"data": "deviceStatusMessage"}, {"data": "quiesce"},
            {"data": "utilization"}, {"data": "coverage"}, {"data": "monoLifeCount"}, {"data": "colorLifeCount"}, {"data": "pageCountThisMonth"},
            {"data": "createdDate"}, {"data": "lastActiveDate"}, {"data": "deviceId"}
        ],
        "columnDefs":
        [
           {
            orderable: false,
            className: 'select-checkbox',
            targets:   0
           },
          { className: "dt-right", "targets": [12,13,14,15,16]}
        ],
        select: {
            style:    'os',
            selector: 'td:first-child'
        },
     "buttons" :
       [
          'colvis',
         { extend: "edit",   editor: editor },
         {
           extend: 'collection',
           text: 'Export',
           buttons:
           [
             { extend: 'print', exportOptions: { columns: [ ':visible' ]}},
             { extend: 'copyHtml5', exportOptions: { columns: [ ':visible' ]}},
             { extend: 'csvHtml5', exportOptions: { columns: [ ':visible' ]}},
             { extend: 'pdfHtml5', exportOptions: { columns: [ ':visible' ]}}
           ]
         }
       ]
    });
    t.buttons().container()
     .appendTo(document.getElementById("buttonPlacement"));
   document.getElementById("deviceTable").style.display="inline";
}

How to add row to DataTable from Json object in ajax success response

$
0
0

Hi,

I have a HTML table in one of the VIEW with 7 data columns and last column have buttons(Actions). Initially it loads and displays data from model collection and I am converting it to Jquery DataTable in $(document).ready() function. So the datatable gets converted and displayed successfully when view is rendered.
Further I have a Add New Record form section below this table and I want to add multiple rows to the datatable through this section. While adding new records on 'onclick' of a Save button I am making ajax call to controller and returning newly added records collection in Json format (return Json(new { Status = "Success", Data = Tasks }, JsonRequestBehavior.AllowGet);
But I am facing issue while adding this object to datatable. Below is my code in $.ajax({... success: section

        if (response.Data != null) {
                    var taskData = response.Data;
                    var taskTable =  $('#tasksTable').DataTable();
                    taskTable.row.add([
                                taskData.Col1,
                                taskData.Col2,
                                taskData.Col3,
                                taskData.Col4,
                                taskData.Col5,
                                taskData.Col6,
                                taskData.Col7,
                                "Actions" : "FIXME"     //added this line by refering to one of the solution on google. no idea how to add
                                                                    buttons in column dynamically
                     ] ).draw();
                }
  1. What is the exact syntax of adding rows to datatable through javascript. Saw many different ways of doing it on google and none is working for me. sometimes it say add method is undefined. sometimes it say 'datatables warning table id example requested unknown parameter '0' for row 4, column 0.' i am getting this error with above syntax. sometimes it was adding multiple rows with all null columns at the top of the table.
  2. How can we add action buttons to datatable dynamically?
  3. What should I use .dataTable() or .DataTable()?

Please suggest a correct solution as I have already spent lot of time on this and got no success.

Thanks.

Viewing all 81388 articles
Browse latest View live


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