Are you the publisher? Claim or contact us about this channel


Embed this content in your HTML

Search

Report adult content:

click to rate:

Account: (login)

More Channels


Showcase


Channel Catalog


Channel Description:

Recent Discussions — DataTables forums

older | 1 | .... | 2314 | 2315 | (Page 2316) | 2317 | 2318 | .... | 2326 | newer

    0 0

    A couple of questions / issues when using Datatables in combination with Parcel bundler.
    I am quite new to bundlers, especially Parcel. So apologies if I misunderstand the instructions.

    Context: using simple example that uses <table> as datatable:

    $('#example').DataTable( {
        dom: 'Bfrtip',
        select: true,
        buttons: [
            'copy', 'excel', 'pdf'//, 'selectAll', 'selected'
        ]
    } );
    

    I used the Datatables download tool (1. framework: DataTables, 2 packages: jQuery 3, DataTables; extensions: Buttons, HTML5 export, JSZip, pdfmake, Print view, Responsive, Select).

    When using download method CDN everything works as expected.

    <link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/v/dt/jq-3.3.1/jszip-2.5.0/dt-1.10.18/b-1.5.4/b-html5-1.5.4/b-print-1.5.4/r-2.2.2/sl-1.2.6/datatables.min.css"/>
    <script type="text/javascript" src="https://cdn.datatables.net/v/dt/jq-3.3.1/jszip-2.5.0/dt-1.10.18/b-1.5.4/b-html5-1.5.4/b-print-1.5.4/r-2.2.2/sl-1.2.6/datatables.min.js"></script>
    

    When using download method Yarn I have several issues. I followed the instructions: added the modules (yarn add), and added the requires to the app.js:

    var $  = require( 'jquery' );
    
    require( 'jszip' );
    require( 'pdfmake' );
    
    require( 'datatables.net-dt' )();
    require( 'datatables.net-buttons-dt' )();
    require( 'datatables.net-buttons/js/buttons.html5.js' )();
    require( 'datatables.net-buttons/js/buttons.print.js' )();
    require( 'datatables.net-responsive-dt' )();
    require( 'datatables.net-select-dt' )();
    

    1) CSS is not loaded?

    I don't see any Datatables CSS being loaded.

    2) no buttons are displayed

    None of the buttons are displayed / visible in the source code.

    3) selectAll, selected, print, give Uncaught Unknown button type

    When I e.g. add selected, selectAll or print I get in the log e.g.: Uncaught Unknown button type: selectAll

    4) pdfmake gives fs error on build

    <path>/node_modules/pdfkit/js/image.js:32:33: Cannot statically evaluate fs argument
    <path>/node_modules/png-js/png-node.js:45:29: Cannot statically evaluate fs argument
    <path>/node_modules/fontkit/index.js:43:31: Cannot statically evaluate fs argument
    <path>/node_modules/pdfkit/js/font/afm.js:11:41: Cannot statically evaluate fs argument
    

    Could be this is related to https://github.com/parcel-bundler/parcel/issues/432
    I tried @import 'datatables.net-dt' but that had no effect (CSS still not loaded).
    I don't get the mentioned error message (main.css:2.1).

    It refers to a blog post, I have the feeling that was not created yet?


    0 0

    I have these columns:

    columns: [
    {data: 'values.0.2'},
    {data: 'values.0.3'},
    {data: 'values.0.4'},
    ]

    I need to get its value separated by commas within a span like this:

    render: function(data, type, row, meta){
    var sequence = "<span class='row.bar'>"1,2,3</span>";
    return sequence

    In other words, you need this:

    <span class='row.bar'>"VALUE ROW 1,VALUE ROW 2,VALUE ROW 3</span>";

    Example:

    If this:

    columns: [
    {data: 'values.0.2'},
    {data: 'values.0.3'},
    {data: 'values.0.4'},
    ]

    Show this:

    <td>1</td>
    <td>2</td>
    <td>3</td>

    I need:

    <span class='row.bar'>1,2,3</span>

    Someone has knowledge on how to obtain this. Thank you.


    0 0

    Hi everyone,
    I want to sort some column, but the values are String type. How can I bind values into the table by their real types, like integer; then sort the column. If the values are string I get sorting like 1,11,2,22,3.....
    So I have 2 questions:
    1. How to bind values by their real type (Int, DateTime...)
    2. How to sort column, if the values are string and I need them to be Int.

    Code HTML:


    0 0

    Object literal may only specify known properties, and 'fixedColumns' does not exist in type 'Settings'.

    I am working in Angular 4 . I use Jquery Datatables Fixed Columns . So that i installed the NPM for Fixed Columns . After I installl , i added the CSS and JS of fixed columns in .angularcli.json file . its properly added .After that i tried to add fixed column property in dtoptions i get this error " Object literal may only specify known properties, and 'fixedColumns' does not exist in type 'Settings'."

    NPM packages which was i installed.

    npm install jquery --save
    npm install datatables.net --save
    npm install datatables.net-dt --save
    npm install angular-datatables --save
    npm install @types/jquery --save-dev
    npm install @types/datatables.net --save-dev

    npm install --save datatables.net-fixedcolumns-dt

    .angularcli.json

    "styles": [
    "src/styles.css",
    "node_modules/datatables.net-dt/css/jquery.dataTables.css",
    "node_modules/datatables.net-fixedcolumns-dt/css/fixedColumns.dataTables.css"
    ],
    "scripts": [
    "node_modules/jquery/dist/jquery.js",
    "node_modules/datatables.net/js/jquery.dataTables.js",
    "node_modules/datatables.net-dt/js/dataTables.dataTables.js",
    "node_modules/datatables.net-fixedcolumns-dt/js/fixedColumns.dataTables.js"
    ]


    0 0

    Hi,
    I've st scrollY and when I select 100 rows for page correctly he shows me the scrollbar.

    $(document).ready(function() {
        var table = $('#clienti').DataTable( {
            data: dataSet,
            responsive: true,
            "scrollY": scrollY + "px",
            "scrollCollapse": true, 
            "processing": true,         
            columns: [
    

    My problem is when I move scroll for example in the middle and then I change page it keeps scrollbar position while I would like it to be positioned to Top.

    I suppose that:

    $(document).ready(function() {
        $('#clienti').on( 'page.dt', function () {alert('Do something on scrollbar'); });
    } );
    

    moreover if I try to use $.fn.dataTable.FixedHeader and move the scrollbar and change page I create a double header at the beginning of my web page, unless you first place the scrollbar by hand to top before changing page!

    Sorry for my english


    0 0

    After adding some custom rendering using the "rowCallback": function (only way I could think to do this) my table is jumpy when navigating using the pagination, I think it is down to the buttons rendering in.

    The page is live here: https://vccalc.vapingcommunity.co.uk/flavours

    I am using an AJAX call to determine the button rendered, so Add to Stash or Remove from Stash is shown depending on the AJAX result.

    "rowCallback": function (row, data) {
    checkInStash(exid, data.flavour_name, data.flavour_company_name).done(function(data){ 
        if(data == true) {
            $(row).addClass( 'instash' );
            $(row).find('td:eq(4)').html('<button class="btn btn-primary flavour-stash">Remove From Stash</button>');
        } else {
            $(row).removeClass( 'instash' );
            $(row).find('td:eq(4)').html('<button class="btn btn-primary flavour-stash">Add To Stash</button>');
        }
    });
    },
    

    This is the AJAX success function:

    success: function(data){
        table.row( 4 ).invalidate().draw('page');
    },
    

    0 0

    I'm looking at the search API and I'm not seeing anything that allows searching for things other than text matches.

    I'd like to be able to build something that handles date ranges (and probably numeric ranges, though I don't have an immediate use case for that)

    I did a quick check in the forums and didn't see anything, but I've had very little luck finding anything using the site search it seems


    0 0

    I am creating a table in a view for a asp.net MVC project. The table template itself is already set up in the view (hardcoded) and i populate the table via javascript using json data from ajax. The table is populating the way I want it too though when I use the Datatable excel button it creates the table in excel but there is no data just the column names.

    For reference I am using the example at https://datatables.net/extensions/buttons/examples/html5/simple.html

    I have all the dependencies listed in the above link. I harcoded one row into the table and that works when I export the table to excel but not my dynamic data from my script.

    I have tried putting the jquery excel button creation code in different parts of my script and that has not work (as you will see in my code) It is only working when i hardcoded a row in the table, not with dynamic data being created and put in the table

    `

    Event Name Start Date End Date Peoplesoft_ID First Name Last Name Workday_ID District Name District Code Donation Date Amount Recurring Periods Gift
    Easter Event Hardcoded Test Hardcoded Test Hardcoded Test Hardcoded Test Hardcoded Test Hardcoded Test Hardcoded Test Hardcoded Test Hardcoded Test Hardcoded Test Hardcoded Test Hardcoded Test
    function loadFunction() { var value_id = $('#myhidden').val(); alert(value_id); $.ajax({ type: 'POST', dataType: 'json', contentType: 'application/json; charset=utf-8', url: '/Admin/ShowEventJSON', data: '{ value_id:' + JSON.stringify(value_id) + '}', success: function (data) { createReport(data) }, error: function () { alert('ajax request error') } }); } //$('#example').DataTable({ // dom: 'Bbfrtip', // buttons: [ // 'copy' // ] //}); //$(document).ready(function () { // $('#tableReport').DataTable({ // dom: 'Bbfrtip', // buttons: [ // 'excelHtml5', // ] // }); //}); //Function to populate table function createReport(data) { var myObj = JSON.parse(data); var table = document.getElementById("tableReport"); for (var i in myObj) { var row = document.createElement('tr'); var valuesArray = Object.values(myObj[i]); for (var v in valuesArray) { var cell = document.createElement('td'); var cellValue = document.createTextNode(valuesArray[v]); cell.appendChild(cellValue); row.appendChild(cell); } table.appendChild(row); } $(document).ready(function () { $('#tableReport').DataTable({ dom: 'Bbfrtip', buttons: [ 'excelHtml5', ] }); }); }

    `


    0 0

    I've been researching how to perform these actions, but finally I simply turned my chair 90 degrees to the right and asked a colleague who is pretty savvy at JavaScript and CSS. He suggested 1 thing which worked and now I'm going to share with everyone since everyone has their own answer but none solved my issue.

    Problem: You've implemented ajax web service, your datatable is fine, but the Search box is way off to the right and page length way off to the left, same with info and paginate. Doing the dom: l, f, i, p thing isn't going to solve it, trying to modify the actual CSS File isn't going to solve it. The answer is simple so let me past below.

    <style>
    .dataTables_wrapper .dataTables_filter {
    right: 300px;
    position: relative;
    }

      .dataTables_wrapper .dataTables_length {
          left: 300px;
          position: relative;
        }
    
      .dataTables_wrapper .dataTables_info {
          left: 300px;
          position: relative;
      }
    
      .dataTables_wrapper .dataTables_paginate {
          right: 300px;
          position: relative;
      }
    </style>
    

    Leave the script references alone, the link references alone. All you need to do is literally copy and past this within the head of your html code. Reload the page and see that the elements have all shifted inwards. Play around with the right and left positions only. The position attribute should be left alone as it is used in conjunction with your right and left pixel definition. I'm by no means a javascript or css expert, I am more C#, full stack software developer. So when I find answers to complex problems I tend to want to share them as I know how frustrating it can be to find a solution to a really complex issue.

    This style tag will override the default positions of the elements and will allow you to design the look and feel of the datatable making your design look just as clean as it does in the examples within this site.

    Good luck everyone


    0 0
  • 12/21/18--02:33: nested table
  • Hello everybody. I am learning also using this plugin. who can take me any example to use it with custom nested table. how can i to get access to nested table


    0 0

    Hi all I am working on to save some values as hidden in the datatable. when end user calls certain event, I want to get these values to perform some functionality.But when I use

    "columnDefs":[
                {
                              "targets": [ 0 ],
                              "Visible": false,
                              "searchable": false
                             }
                         ]
    

    it remove/delete columns completely from datatable so I cant access this column value.
    How can I create hidden columns to contain some values that I can access as per desire.


    0 0
  • 01/07/19--03:40: Recommendations please
  • I am asking what software is recommended for creating a website (that needs the minimum of coding experience) and to work easily with DataTables?

    Any pointers appreciated.


    0 0

    I have a table that makes use of row.child where each row is expandable/collapse-able, but my parent rows can and will have duplicate data. Is it possible to rowGroup the multiple duplicate parent rows and still maintain the expandable/collapse-able functionality from row().child?

    The following is what I've tried, but it doesn't provide the expected results:

    function loadDataTable(data) {
        var table = $('#List').DataTable({
            "data": data,
            "columns": [
                {
                    "className": 'details-control',
                    "orderable": false,
                    "defaultContent": ''
                },
                { "data": "SomeVal1" },
                { "data": "SomeVal2" },
                { "data": "SomeVal3" },
                { "data": "SomeVal4" },
                { "data": "SomeVal5" },
                { "data": "SomeVal6" },
                { "data": "SomeVal7" }
    
    
            ],
            "rowGroup": {
                dataSrc: 'SomeVal1'
            },
            "order": [[1, 'asc']]
        });
    
        $('#List tbody').on('click', 'td.details-control', function () {
            var tr = $(this).closest('tr');
            var row = table.row(tr);
    
            if (row.child.isShown()) {
                // This row is already open - close it
                row.child.hide();
                tr.removeClass('shown');
            }
            else {
                // Open this row
                row.child(format(row.data())).show();
                tr.addClass('shown');
            }
        });
    
    };
    

    0 0

    I am using aspnetcore 2.2 MVC application. populating datatable from linq where I specified orderbydescending(x==> x.logintime) this column login time is formated to format to display as below

    Display(Name = "Login Time")]
    [DisplayFormat(DataFormatString = "{0:MM/dd/yyyy HH:mm}", ApplyFormatInEditMode = true)]
    //[DataType(DataType.DateTime)]
    public DateTime LoginTime { get; set; }

    when I load the datatable, the first column is not getting sorted. what would be the issue ? please find attached data populated. I am using below sequence of js, css files

    ----below is the view page in mvc. where "UserAccessLogs" is the name of table-- table data is in attachment.


    <script src="@Url.Content("~/lib/DataTables/DataTables-1.10.18/js/jquery.dataTables.js")"></script>
    <link rel="stylesheet" type="text/css" href="@Url.Content("~/lib/DataTables//DataTables-1.10.18/css/datatables.min.css")">
    <link rel="stylesheet" type="text/css" href="@Url.Content("~/lib/DataTables/DataTables-1.10.18/css/jquery.dataTables.min.css")">
    <link rel="stylesheet" type="text/css" href="@Url.Content("~/lib/DataTables/DataTables-1.10.18/css/dataTables.bootstrap4.min.css")" />
    <script src="@Url.Content("~/lib/DataTables/Select-1.2.6/js/dataTables.select.min.js")"></script>
    <link rel="stylesheet" type="text/css" href="@Url.Content("~/lib/DataTables/Select-1.2.6/css/select.bootstrap4.min.css")" />
    <link rel="stylesheet" type="text/css" href="@Url.Content("~/lib/DataTables/Buttons/1.5.2/css/buttons.dataTables.min.css")" />
    <script type="text/javascript">
    $(document).ready(function () {

            $("#UserAccessLogs").DataTable({
                select: 'single',
                "lengthChange": false,
                "pageLength": 20,
                "pagingType": "full_numbers",
              **  "order": [[0, "desc"]]**
                //"columnDefs": [
                //    { "targets": 0, "visible": false }
                //]
            });
            //var table = $('#UserAccessLogs').DataTable();
            //$('#UserAccessLogs tbody').on('click', 'tr', function () {
            //    if ($(this).hasClass('selected')) {
            //        $(this).removeClass('selected');
            //    }
            //    else {
            //        table.$('tr.selected').removeClass('selected');
            //        $(this).addClass('selected');
            //    }
            //});
        });
    </script>
    

    }

    also find attached output


    0 0

    So I have an ajax call that is returning data that contains two objects at the root. One is LastRefresh which is just the number of ticks and I'm not using it with my DataTable but I am using elsewhere. The other is a list of strings (SKUs) which I want to display in a DataTable. The data comes back fine but I haven't been successful yet in having datatables use the nested object called SKUs.

              fbaSKUTable = $('#fbaSKUs').DataTable({
                    ajax: {
                        'url': '/api/FBA/RefreshSKUS',
                        'dataSrc': 'skuData',
                        'type': 'GET',
                        'success': function (data) {
                            skuData = JSON.stringify(data.SKUs);
                            storage.setItem("lastRefresh", JSON.stringify(data.LastRefresh));
                            storage.setItem("fbaSKUs", JSON.stringify(data.SKUs));
                        },
                        'failure': function (data) {
                            console.log('failure');
                        }
                    },
                    "columns": [
                        {"SKU": "SKU"}
                    ]
                });
    

    Here is some sample data

    {"LastRefresh":"636826452200968391","SKUs":[{"SKU":"AB-BROWN"},{"SKU":"ZAR-FEO1"},{"SKU":"ZZZ-FROST"}]}
    

    0 0

    as you can see, when I start edit radio type, it will jump to the begin position, and I have to scroll to the field , and when I change the select, It is also jumping to the begin position.


    0 0

    When an inline editor is opened on Selectize field, the table jumps to the beginning of the table


    0 0
  • 01/09/19--23:55: error on page for datatable
  • i am getting this error on a page

    DataTables warning: table id=example - Ajax error. For more information about this error, please see http://datatables.net/tn/7


    0 0
  • 01/10/19--02:31: Individual Fixed Columns?
  • Hey everybody,
    I was wondering, if its possible to set the fixed columns not just from the left side of my DT. Is it possible to fix only the 2nd and 3rd column?
    Thanks!
    Cheeres,
    Mert


    0 0
  • 01/10/19--03:13: Date is not sort in order
  • I am retrieving the data from database and showing it in my html. My first column is date. Here is the sample output

    01-01-2019  SBI_OD  Own Transfer    
    01-01-2019  SBI_S   Own Transfer    
    01-12-2018  SBI_OD  Initial         
    01-12-2018  ICICI_S Initial         
    01-12-2018  SBI_S   Initial         
    01-12-2018  ICICI_S Debit           
    01-12-2018  ICICI_S Debit           
    01-12-2018  ICICI_S Debit           
    01-12-2018  SBI_OD  Own Transfer    
    01-12-2018  SBI_S   Own Transfer    
    01-12-2018  ICICI_S Debit           
    01-12-2018  ICICI_S Own Transfer    
    01-12-2018  SBI_OD  Credit          
    01-12-2018  SBI_S   Own Transfer    
    02-01-2019  ICICI_S Debit           
    

    As you can see, the date suppose to start with 01-12-2018, but its sorting from 01-01-2019. I have verified the post https://datatables.net/blog/2014-12-18 and added moment.min.js and datetime-moment.js to my site.

    This is my code which will retrieve data from database on form submit using AJAX:

    function analyzedata() {
    
       var data1 = $("#analyze_options_select").val();
       var yeardata = $("#year").val();
       var monthdata = $("#analyze_options_month").val();
        var startdate = $("#start_date").val();
       var enddate = $("#end_date").val();
    
         $.ajax({ 
    
                url  :ajaxurl,
                type :'POST',
                data: { 'action': 'analyzedata','analyze_options':data1,'analyze_options_month':monthdata,'year':yeardata,'start_date':startdate,'end_date':enddate},
    
                success: function(data){
    
                        $("#example tbody").html(data);
                        $.fn.dataTable.moment( 'dd-MM-YYYY' );
    
    
                            var table = $('#example').DataTable({
    
                            retrieve: true,
                            paging: false, 
                            columnDefs: [
                                            {
                                            targets:0,
                                            type: 'string'
                                            }
                                        ]
                            });
    
                            table.rows.add($(data)).draw();
    
                        }
            });
    
        }; 
    

    As mentioned in the post, I have added code $.fn.dataTable.moment( 'dd-MM-YYYY' ); but its not working. Can someone guide me how to resolve this ?


older | 1 | .... | 2314 | 2315 | (Page 2316) | 2317 | 2318 | .... | 2326 | newer