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 | .... | 2257 | 2258 | (Page 2259) | 2260 | 2261 | .... | 2326 | newer

    0 0

    I want to share a discussion I opened about the inclusion of the Eonasdan DateTimePicker within a DataTables component. I do not use the Editor component but DataTables. But it is strange that using an HTML table does not present this problem where the popover (.bootstrap-datetimepicker-widget) with the Calendar is displayed inside the cell and not on top: https://github.com/Eonasdan/bootstrap-datetimepicker/issues/2274


    0 0

    How to use the dataTable as inline table? I don't want to use the full width because another inline element should be placed next to it. But there is a bug when used with the responsive extension.

    To reproduce the problem:
    Go to http://live.datatables.net/rinorupo/3/edit?html,css,js,output
    Resize the output window to show all, then hide the last column and afterwards try to get the last column back.

    Is there a class to set like https://datatables.net/manual/styling/classes or another solution?


    0 0

    Hello Everyone,

    I am struggling for hours now, i got a function which is called editMember in javascript, what i am trying to do is pass my columns "Data"."0" when the edit button is clicked.

    I am getting an error

    Uncaught ReferenceError: data is not defined at HTMLAnchorElement.onclick (index.php:1)

    Here is code:

    `
    "columns": [

                { "data": "0", "name": "0", "autoWidth": true },
                    { "data": "1", "name": "1", "autoWidth": true },
                    { "data": "2", "name": "2", "autoWidth": true },
                    { "data": "3", "name": "3", "autoWidth": true },
         {
    
        "orderable":      false,
                "data":  "null",
                "className": "center",
                "defaultContent": '<a type="button" class="btn btn-primary"  data-toggle="modal" data-target="#editMemberModal"  onclick="editMember(data[0])"> <span class="glyphicon glyphicon-edit"></span>Edit</a> / <a href="" class=class="btn btn-danger">Delete</a>'
            }
    

    `
    Please can someone help?

    onclick="editMember(data[0])"


    0 0
  • 11/19/18--18:24: Global validator and xss
  • I'd like to set xss to false for all the fields of a specific instance of Editor. Is this possible?

    Would using a global validator be the appropriate place?


    0 0
  • 11/19/18--21:58: Form inside table row
  • In My project i want to add inline editing of full row and by clicking on update that row data should be submitted and by clicking on new button blank row should be added in table, but however i am not able to submit form inside table row. How i can achieve this?

    PS: Taking a form outside table is not possible.


    0 0

    Hi guy!

    With the help of Allan, I managed to find a workaround for real time effect on Datatables Editor.

    It is not easy to integrate web socket with inline editing. Here is the concept for workaround:

    1. Use ajax.reload() - to refresh the table (without refreshing the page)
    2. Use setInterval() - to set frequency for auto refresh
    3. Use clearInterval() - to stop auto refresh only when editing in the cell

    That will give you a real time experience to your clients!

    Steps:

    File: js/table.youTableName.js
    1.

     //Auto Refresh (ajax.reload)
        var refreshTable = setInterval( function () {
            table.ajax.reload( null, false ); // user paging is not reset on reload
            table.keys.enable();  
        }, 3000 );  //3000 means 3 seconds; you cannot put 0 -> error
    

    2.

        //   Activate an inline edit on click of a table cell
         $('#youTableName').on( 'keyup', 'tbody td:not(:first-child)', function (e) {
             clearInterval( refreshTable );
             table.keys.disable();
         });
            
        // Inline editing on tab focus
        $('#youTableName').on( 'keydown', 'tbody td:not(:first-child)', function (e) {
              
          clearInterval( refreshTable );
          table.keys.disable();
    
      });
    
      //   Activate an inline edit on click of a table cell
         $('#youTableName').on( 'click', 'tbody td:not(:first-child)', function (e) {
             editor.inline( this, {
                 submitOnBlur: true
             });
             clearInterval( refreshTable );
             table.keys.enable();
         });
    
    //Additional codes if you want to submit using TAB in inline editing
        // when tab key is pressed  
        $('#youTableName').on( 'keydown', 'tbody', function (e) {
            if(e.which == 9) {                                      
                e.preventDefault();
                var $input = $('form input');
                $input.eq( $input.index( this ) + 1 ).focus();
                table.keys.enable();
            }
       } );
    

    0 0

    Hi guys!

    If you want to update another field based on a field you update, you may want to use this snippet:

    File: table.yourtable.js

    $( editor.field( 'firstField' ).input() ).on( 'keyup', function (e, d) {
    if ( ! d || ! d.editor ) {
    
      editor.field( 'secondField' ).val( "Closed");        //Once 1st field is edited, it will also save the value, "Closed" into 2nd field
      editor.field( 'updated_by' ).val( username);      //Assign updated_by user
    
    }
    } );
    

    ------ end --------


    0 0

    I need to hide several columns from the list of the colvis button.

    columns: ':gt(2)' - works, but it hides all 3 columns before the column #3 (and I just need to hide column #3). Is there a way to pass an array of the columns that must be hidden to this funtion? For example, I want to hide columns #3, #5, #9


    0 0

    Hi guys!

    If you want to change colour of the cell based on the value you have selected or being updated from another cell, you can use the snippet below:

    File: js/tables.YourTableName.js

            //Status
            { "width": 50, "targets": 2 ,
                render: function (data, type, full, meta) {
    
                    if (data == "Open") {
                    return "<div class='text-wrap width-50 green-background'>" + data + "</div>";
                    }else{
                        return "<div class='text-wrap width-50'>" + data + "</div>";
                    }
                }
    
            },
    

    -- end--

    File: style.css

    /Control for Data Fields Color Change/
    .green-background {
    background-color: green;
    color: white;
    }

    -- end --

    ** It would help if someone could provide the code to change the entire row color also!


    0 0

    First If I am selecting two checkboxes in that case it's enabling the action button . But if I do uncheck one checkbox in that case it's disable the action buttons , even one checkbox is checked and one is unchecked.

    Can anyone help on this issue


    0 0

    I have created a datatable and saved the state at server-side(using callback method "stateSaveCallback") and load the state using callback method "stateLoadCallback". But when I render the row column(using trigger col[0].render = function (data, type, row) {
    ......
    ......
    }), datatable's state changed.


    0 0

    Hi guys,
    I have a problem with datatable, server-side processing.
    I have a lot of data, so server-side processing is needed to display them properly.
    The first rendering of the datatable is ok, but when I try to change order by column I'm stuck at "processing", sever side call is done properly, data are returned, but nothing happens on the already displayed table.

    This is my code, any help?

    $('#tbl_orders').dataTable({
                "processing": true,
                "serverSide": true,
                "ajax": {
                    "url": "ajax.php?act=Orders&method=GetOrders"
                    , "contentType": "application/json; charset=utf-8"
                    , "dataType": 'json'
                    , "dataSrc": function ( json ) {
                        json.draw = json.data.draw;
                        json.recordsTotal = json.data.recordsTotal;
                        json.recordsFiltered = json.data.recordsFiltered;
                        return json.data.data;
                    }
                    , "dataFilter": function(reps) {
                        return reps;
                    }, "error":function(err){
                        console.log(err);
                    }
                }
                , "order": [[ 1, "desc" ]]
                , "columns": [
                    {
                        "data": "ch"
                        , 'name': 'channel'
                        , "render": function ( data, type, row, meta ) {
                            return data;
                        }
                    }
                    , {
                        "data": "dp"
                        , 'name': 'date_purchased'
                    }
                    , {
                        "data": "oId"
                        , 'name': 'order_id'
                    }
                    , {
                        "data": "sn"
                        , 'name': 'shipping_name'
                    }
                    , {
                        "data": "pr"
                        , 'name': 'products'
                        , "render": function ( data, type, row, meta ) {
                            return data;
                        }
                    }
                    , {
                        "data": "st"
                        , 'name': 'order_status'
                        , "render": function ( data, type, row, meta ) {
                            return data;
                        }
                    }
                    , {
                        "data": "sch"
                        , 'name': 'email_scheduled'
                        , "render": function ( data, type, row, meta ) {
                            return data;
                        }
                    }
                ]
                , "colReorder": true
            });
    

    Thank you


    0 0

    I have a table:

    <table data-url="test.com"></table>
    

    and in js:

    $('table').DataTable({
        "processing": true,
        "serverSide": true,
        "ajax": {
            "url": "---------------------",
            "dataSrc": "data",
            "type": "POST"
        },
        "columns": [
            {"data": "id"},
            {"data": "title"},
            {"data": "title_en"},
            {"data": "status"},
            {"data": "city"},
            {"data": "html"}
        ]
    });
    

    I want to use each table's data-url for datatable ajax URL.
    Can I do this?


    0 0

    Hello
    How can i use a join with Editor PHP librairies in my php file.
    I would like to use a syntaxe like this with on join between two tables.

    include_once( $_SERVER['DOCUMENT_ROOT']."/php/DataTables.php" );

    $countries = $db
    ->select( 'country', ['id as value', 'name as label'], ['continent' => $_REQUEST['values']['continent']] )
    ->fetchAll();

    Thanks for your help.
    Lionel


    0 0

    I use datatable PrimeNG with virtual scroll.
    when I scroll, the table doesn't display all the rows i have loaded.
    Maybe I have a problem in my code?
    this is my code:
    loadLazy(event: LazyLoadEvent) {
    this.filters = event.filters;
    this.loading = true;
    setTimeout(() => {
    this.loading = false;
    if (this.displayList) {
    let list = this.displayList.filter(row => this.filterField(row, event.filters));
    this.displayList1 = list.slice(event.first, (event.first + event.rows));
    this.totalRecords = list.length;
    }

    }, 250);
    

    }
    the view:
    before scroll:

    after scroll:

    I have more rows than displayed rows.


    0 0

    I don't seem to be able to get the row with the hide show image to display and the hidden td is displayed.
    i didn't understand exact what is the problem

    var columnDefs = [
    {
    "className": 'details-control',
    "orderable": false,
    "data": null,
    "defaultContent": '',
    targets: 0
    }, {
    title: "Id",
    data: [0],

                    }, {
                        title: "Document Name",
                        data: [1],
                    }, {
                        title: "Active",
                        data: [2],
                        "createdCell": function (td, cellData) {
                            if (cellData === 1) {
                                $(td).html("<i class=\"fa fa-check text-success\"></i>");
                            } else {
                                $(td).html("<i class=\"fa fa-check text-danger\"></i>");
                            }
                        }
                    }, {
                        title: "Document Category Id",
                        data: [3],
                    }, {
                        title: "created_at",
                        data: [4],
    
    
                    }, {
                        title: "Created by",
                        data: [5],
    
                    } ,{
                        title: "Updated at",
                        data: [6],
                        visible: false
    
                    },{
                        title: "Updated by",
                        data: [7],
                        visible: false
    
    
                    }
    
                ];
    
    
                myTable = $('#example').DataTable({
                    data: dataSet,
                    columns: columnDefs,
                    dom: 'Bfrtip',
                    idSrc: 0,
                    buttons: [
                        {
                            extend: 'copyHtml5',
                            text: '<i class="fa fa-files-o"></i> copy',
                            titleAttr: 'Copy'
                        },
                        {
                            extend: 'excelHtml5',
                            text: '<i class="fa fa-file-excel-o"></i> excel',
                            titleAttr: 'Excel'
                        },
    
                        {
                            extend: 'pdfHtml5',
                            text: '<i class="fa fa-file-pdf-o"></i> PDF',
                            titleAttr: 'PDF',
                            orientation: 'landscape',
                            pageSize: 'LEGAL'
                        },
    
    
                    ],
                    select: true,
                    responsive: {
                        details: {
                            type: 'column',
                            target: 'tr'
                        }
                    },
                    order: [[1, 'asc']],
                });
    

    0 0

    i'm trying to show columns in separate child row but its not working i didnot understand what's the exact problem
    help me thank you,

    var columnDefs = [
    {
    "className": 'details-control',
    "orderable": false,
    "data": null,
    "defaultContent": '',
    targets: 0
    }, {
    title: "Id",
    data: [0],

                    }, {
                        title: "Document Name",
                        data: [1],
                    }, {
                        title: "Active",
                        data: [2],
                        createdCell: function (td, cellData) {
                            if (cellData === 1) {
                                $(td).html("<i class=\"fa fa-check text-success\"></i>");
                            } else {
                                $(td).html("<i class=\"fa fa-check text-danger\"></i>");
                            }
                        }
                    }, {
                        title: "Document Category Id",
                        data: [3],
                    }, {
                        title: "created_at",
                        data: [4],
    
    
                    }, {
                        title: "Created by",
                        data: [5],
    
                    } ,{
                        title: "Updated at",
                        data: [6],
                        visible: false
    
                    },{
                        title: "Updated by",
                        data: [7],
                        visible: false,
                        className: 'none',
                    }
    
                ];
    
    
                myTable = $('#example').DataTable({
                    data: dataSet,
                    columns: columnDefs,
                    dom: 'Bfrtip',
                    idSrc: 0,
                    buttons: [
                        {
                            extend: 'copyHtml5',
                            text: '<i class="fa fa-files-o"></i> copy',
                            titleAttr: 'Copy'
                        },
                        {
                            extend: 'excelHtml5',
                            text: '<i class="fa fa-file-excel-o"></i> excel',
                            titleAttr: 'Excel'
                        },
    
                        {
                            extend: 'pdfHtml5',
                            text: '<i class="fa fa-file-pdf-o"></i> PDF',
                            titleAttr: 'PDF',
                            orientation: 'landscape',
                            pageSize: 'LEGAL'
                        },
    
    
                    ],
                    select: true,
                    responsive: {
                        details: {
                            type: 'column',
                            target: 'tr'
                        }
                    },
                    order: [[1, 'asc']],
                });
    

    0 0

    I'm sure this is very simple but I cannot find it...

    "footerCallback": function( tfoot, data, start, end, display ) {
        var api = this.api();
    
        var theColumnTotal = api
            .column( 4 )
            .data()
            .reduce( function (a, b) {
                if(isNaN(a)){
                    return '';
                } else {
                    a = parseFloat(a);
                }
                if(isNaN(b)){ 
                    return '';
                } else {
                    b = parseFloat(b);
                }
                return (a + b).toFixed(2);
            }, 0 );
    
        // Update footer
        $( api.column( 4 ).footer() ).html(
            theColumnTotal / [NEED ROW COUNT HERE]
        );
    }
    

    Let me know if there is any further info needed, thanks!


    0 0

    Data Table

    $(document).ready(function() {
    
    
          var advance = $('#advanced-table').DataTable( {
                  
            
          dom: 'B<"clear">lfrtip',
      
        "processing": true,
        "serverSide": true,
    
          "ajax":{
                            url :"server_processing.php ", // json datasource
                            type: "post",  // method  , by default get
                            
                        },
             
    
          
              mark: true,
               columnDefs: [
                {
                    targets: 1,
                    className: 'noVis',
            
                },
                {
                    "targets": [ 6 ],
                    "visible": false
                },
                {
                    "targets": [ 7 ],
                    "visible": false
                }   
                
            ],
          
        buttons: {
            name: 'primary',
    
            buttons: [ 'copy', 'csv', 'excel', 'pdf', 'print', 'colvis'  ]
        },
              
              
      
        
              //"language": {
                    //"url": "http://cdn.datatables.net/plug-ins/1.10.13/i18n/Portuguese-Brasil.json"
               // } 
              
       
        } );
    
        
        $('a.toggle-vis').on( 'click', function (e) {
            e.preventDefault();
     
            // Get the column API object
            var column = advance.column( $(this).attr('data-column') );
    
            // Toggle the visibility
            column.visible( ! column.visible() );
        } );  
        
    
    
    // Setup - add a text input to each footer cell
        $('#advanced-table tfoot th').each( function () {
            var title = $(this).text();
            $(this).html( '<div class="md-input-wrapper"><input type="text" class="md-form-control" placeholder="Pesquisar '+title+'" /></div>' );
        } );
          // Apply the search
        advance.columns().every( function () {
            var that = this;
     
            $( 'input', this.footer() ).on( 'keyup change', function () {
                if ( that.search() !== this.value ) {
                    that
                        .search( this.value )
                        .draw();
                }
            } );
        } );
    
        
    
        } );
    

    server_processing.php

    <?php
    /* Database connection start */
    $servername = "localhost";
    $username = "root";
    $password = "";
    $dbname = "entt";
    
    $conn = mysqli_connect($servername, $username, $password, $dbname) or die("Connection failed: " . mysqli_connect_error());
    
    /* Database connection end */
    
    
    // storing  request (ie, get/post) global array to a variable  
    $requestData= $_REQUEST;
    
    
    $columns = array( 
    // datatable column index  => database column name
        0 =>'ID', 
        1 =>'Nome', 
        2 => 'E-mail',
        4 => 'Cidade',
        5 => 'Estado',
        6 => 'Cep',
        7 => 'Data',
        8 => 'Hora',
        9 => 'Status'
    );
    
    // getting total number records without any search
    $sql = "SELECT id, email, nome, cidade, estado, cep, data, hora ";
    $sql.=" FROM usuarios";
    $query=mysqli_query($conn, $sql) or die("server_processing.php: get usuarios");
    $totalData = mysqli_num_rows($query);
    $totalFiltered = $totalData;  // when there is no search parameter then total number rows = total number filtered rows.
    
    
    $sql = "SELECT id, email, nome, cidade, estado, cep, data, hora ";
    $sql.=" FROM usuarios WHERE 1=1";
    if( !empty($requestData['search']['value']) ) {   // if there is a search parameter, $requestData['search']['value'] contains search parameter
        $sql.=" AND ( id LIKE '".$requestData['search']['value']."%' "; 
        $sql.=" OR nome LIKE '".$requestData['search']['value']."%' ";
        $sql.=" OR email LIKE '".$requestData['search']['value']."%' ";
        $sql.=" OR cidade LIKE '".$requestData['search']['value']."%' )";
        $sql.=" OR estado LIKE '".$requestData['search']['value']."%' )";
        $sql.=" OR cep LIKE '".$requestData['search']['value']."%' )";
        $sql.=" OR data LIKE '".$requestData['search']['value']."%' )";
        $sql.=" OR hora LIKE '".$requestData['search']['value']."%' )";
    }
    $query=mysqli_query($conn, $sql) or die("server_processing.php: get usuarios");
    $totalFiltered = mysqli_num_rows($query); // when there is a search parameter then we have to modify total number filtered rows as per search result. 
    $sql.=" ORDER BY ". $columns[$requestData['order'][0]['column']]."   ".$requestData['order'][0]['dir']."  LIMIT ".$requestData['start']." ,".$requestData['length']."   ";
    /* $requestData['order'][0]['column'] contains colmun index, $requestData['order'][0]['dir'] contains order such as asc/desc  */    
    $query=mysqli_query($conn, $sql) or die("server_processing.php: get usuarios");
    
    $data = array();
    while( $row=mysqli_fetch_array($query) ) {  // preparing an array
        $nestedData=array(); 
    
        $nestedData[] = $row["id"];
        $nestedData[] = $row["nome"];
        $nestedData[] = $row["email"];
        $nestedData[] = $row["cidade"];
        $nestedData[] = $row["estado"];
        $nestedData[] = $row["cep"];
        $nestedData[] = $row["data"];
        $nestedData[] = $row["hora"];
        $data[] = $nestedData;
    }
    
    
    
    $json_data = array(
                "draw"            => intval( $requestData['draw'] ),   // for every request/draw by clientside , they send a number as a parameter, when they recieve a response/data they first check the draw number, so we are sending same number in draw. 
                "recordsTotal"    => intval( $totalData ),  // total number of records
                "recordsFiltered" => intval( $totalFiltered ), // total number of records after searching, if there is no searching then totalFiltered = totalData
                "data"            => $data   // total data array
                );
    
    echo json_encode($json_data);  // send data as json format
    
    ?>
    

    DataTables warning: table id=advanced-table - Requested unknown parameter '8' for row 0, column 8. For more information about this error, please see http://datatables.net/tn/4


    0 0

    Hi all together,

    https://datatables.net/extensions/rowgroup/examples/initialisation/customRow.html

    I like to have a possibility to click on the group name like "Averages for Edinburgh" and the group should expand/collapse. Per default when loading the site, the group should be collapsed.

    For doing that, I also found this thread here, where redwall was able to embed such a function for his DataTable:
    https://datatables.net/forums/discussion/comment/61474/#Comment_61474

    But my Javascript skills are less than available :)

    Would someone of you be so kind and help me out here? How can I reach the above described functionality on the basic example of "Custom row rendering / aggregates"?

    Thank you for your help!!


older | 1 | .... | 2257 | 2258 | (Page 2259) | 2260 | 2261 | .... | 2326 | newer