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

baby carriers for dads suppliers

$
0
0

Our History
Located in Xiamen, Fujian Province. We specilized in producing mother and baby products more then 10years. Quality is our culture,We are sure that our high quality products and excellent services will attract more and more customers' appreciation.
Our Factory
There are more than one hundred employees in our company. We made the baby carrier ,diaper bag with the most eco-friendly and the most innovative materials.
Our Product
Diaper bag ,baby carrier, changing mat and other baby accessories ect.
Product Application
Baby carrier for 0-3 years baby ,diaper bag for and Mom and Dad.
Our Certificate
Our factory are well managed to reach ISO9001 standards .Also we applied social audit such as BSCI, SEDEX, SGS. For our products, we have passed the certification of EN-71,CE ect.
Production Equipment
Cutting Machine,Flat Sewing Machine ,High Head Sewing Machine,Pattern Sewing Machine ect.
Production Market
Our products have good reputation in Europe, America ,UK, Canada and etc.
Our Service
OEM &ODM are welcomed,Quality-Oriented,Customer -Orientedbaby carriers for dads suppliers
website:http://www.ababyproduct.com/


How to get recordsTotal from response header

$
0
0

Hi!
I'm using ajax request to fill dataTable. The API returns totalcount in "Response header" (I can't change the api).How can I reach response header to get totalcount in ajax call

$('#' + tableId).DataTable({
            serverSide: true,
            processing: true,
            ajax: {
                url: myUrl,
                data: function (d) {
                    var pageIndex = d.start / d.length;
                    var pageSize = d.length;
                    var sortCol = columns[d.order[0].column].data; // Get column name from column index
                    var sort = sortCol + ',' + d.order[0].dir; // API sort format : "colName,direction"
                    var searchValue = d.search.value;
                    return $.extend({}, "", {
                        "page": pageIndex,
                        "size": pageSize,
                        "sort": sort,
                        "search": searchValue
                    });
                },
                async: false,
                type: 'GET',
                headers: {
                    'Authorization': authorization
                },
                dataFilter: function (data) { // Rename json props to satisfy datatable expectations.
                    var json = {};
                    json.recordsTotal = 26; // **responseHeader.total**
                    json.recordsFiltered = 26; // **responseHeader.total**
                    json.data = jQuery.parseJSON(data); // data.result
                    return JSON.stringify(json); // return JSON string
                },

Replace text for imagen

$
0
0

Hi, I'm using Datatable, in some columns I have a 1 or a 0, and I want to replace this 1 or 0 in an imagen..

It is possible?

With html table I know how to do it, but with DataTable not..

Thanks

How do you install/configure datatables using webpack-encore?

$
0
0

I've done 'yarn add datatables.net', and I can see that it's loading, but the css isn't loading.

I'm sure it's a very basic configuration issue related to webpack.

Thanks!

How to Disable Editor Dependent on Action Edit

$
0
0

Hello Allan,

How to Disable Editor Dependent on Action Edit.
For example, i have 2 select fields, country and city.
I find this answer from you, but not help me much.

Is there any built in function to disable dependent on edit? Please advise, thank you

error 500 on search

$
0
0

hello. when I want to filter my table, the browser gives me an alert http://datatables.net/tn/7.
this is my code :

$("#grid").dataTable({
            "processing": true, // control the processing indicator.
            "serverSide": true, // recommended to use serverSide when data is more than 10000 rows for performance reasons
            "info": true,   // control table information display field
            "stateSave": true,  //restore table state on page reload,
            "searching": true,
            "language": {
                "url": "/translate/datatables.fa-IR.json"
            },
            "lengthMenu": [[10, 20, 50, -1], [10, 20, 50, "All"]],    // use the first inner array as the page length values and the second inner array as the displayed options
            "ajax": {
                "url": serviceBase + "/Auth/Admin/SearchOrders2/",
                "type": "GET",
                'beforeSend': function (xhr) {
                    xhr.setRequestHeader("Authorization", "Bearer " + localStorageService.get("authorizationData").token);
                }
            },
            "columns": [
                { "data": "customerContact", "orderable": true },
                { "data": "isDone", "orderable": true },
                {
                    "mRender":
                        function (data, type, row) {
                            var xxx = $scope.name1 = $filter("jalaliDateFromNow")(row["createdDate"]);
                            return "<span>" + $filter("jalaliDateFromNow")(row["orderCreationTime"]); +'</span>';
                        }, "orderable": true
                },
                { "data": "totalPrice", "orderable": true },
                { "data": "count", "orderable": true },
                { "data": "description", "orderable": true },
                {
                    "mRender": function (data, type, row) {
                        return '<button class="btn btn-sm btn-circle green tooltips" disabled="disabled"><i class="fa fa-check"></i><span>جزئیات</span></button>'
                    },
                    "orderable": false
                }
            ],
            "order": [[0, "desc"]]
        });

which part of my code is wrong?

Hi, I Question a Problems (Download selected file on DataTables)

$
0
0

I have added a datatables script on the website. I listed the files added in a folder in the DataTables context. I want to download the files in the list, but I could not place the script somewhere

Code Examples download


LINKS in SERVERSIDE

$
0
0

I have a table in mysql that contains a column with an id. I want to add in my table a link for each row with the same address that only depends on that id. How can I do it?

PHP

<?php
/* Database connection start */


$conn = mysqli_connect($servername, $username, $password, $dbname) or die("Connection failed: " . mysqli_connect_error());
mysqli_set_charset($conn, "utf8");
/* Database connection end */


// storing  request (ie, get/post) global array to a variable
$requestData= $_REQUEST;


$columns = array(
// datatable column index  => database column name
    0 =>'titulo',
    1 => 'descripcion'
);

// getting total number records without any search
$sql = "SELECT titulo, descripcion  ";
$sql.=" FROM ocios";
$query=mysqli_query($conn, $sql) or die("employee-grid-data.php: get employees");
$totalData = mysqli_num_rows($query);
$totalFiltered = $totalData;  // when there is no search parameter then total number rows = total number filtered rows.


if( !empty($requestData['search']['value']) ) {
    // if there is a search parameter
    $sql = "SELECT titulo, descripcion ";
    $sql.=" FROM ocios";
    $sql.=" WHERE titulo LIKE '".$requestData['search']['value']."%' ";
    // $requestData['search']['value'] contains search parameter
    $sql.=" OR descripcion LIKE '".$requestData['search']['value']."%' ";

    $query=mysqli_query($conn, $sql) or die("employee-grid-data.php: get employees");
    $totalFiltered = mysqli_num_rows($query); // when there is a search parameter then we have to modify total number filtered rows as per search result without limit in the query

    $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 , $requestData['start'] contains start row number ,$requestData['length'] contains limit length.
    $query=mysqli_query($conn, $sql) or die("employee-grid-data.php: get employees"); // again run query with limit

} else {

    $sql = "SELECT titulo,  descripcion";
    $sql.=" FROM ocios";
    $sql.=" ORDER BY ". $columns[$requestData['order'][0]['column']]."   ".$requestData['order'][0]['dir']."   LIMIT ".$requestData['start']." ,".$requestData['length']."   ";
    $query=mysqli_query($conn, $sql) or die("employee-grid-data.php: get employees");

}

$data = array();
while( $row=mysqli_fetch_array($query) ) {  // preparing an array
    $nestedData=array();

    $nestedData[] = $row["titulo"];
    $nestedData[] = $row["descripcion"];

    $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

?>

HTML

<!DOCTYPE html>
<html>
    <title>Datatable Demo1 | CoderExample</title>
    <head>
        <link rel="stylesheet" type="text/css" href="css/jquery.dataTables.css">
        <script type="text/javascript" language="javascript" src="js/jquery.js"></script>
        <script type="text/javascript" language="javascript" src="js/jquery.dataTables.js"></script>
        <script type="text/javascript" language="javascript">
            $(document).ready(function() {
                var dataTable = $('#employee-grid').DataTable( {
                    "processing": true,
                    "serverSide": true,
                    "ajax":{
                        url :"employee-grid-data.php", // json datasource
                        type: "post",  // method  , by default get
                        error: function(){  // error handling
                            $(".employee-grid-error").html("");
                            $("#employee-grid").append('<class="employee-grid-error"><tr><th colspan="3">No data found in the server</th></tr>');
                            $("#employee-grid_processing").css("display","none");

                        }
                    }
                } );
            } );
        </script>
        <style>
            div.container {
                margin: 0 auto;
                max-width:760px;
            }
            div.header {
                margin: 100px auto;
                line-height:30px;
                max-width:760px;
            }
            body {
                background: #f7f7f7;
                color: #333;
                font: 90%/1.45em "Helvetica Neue",HelveticaNeue,Verdana,Arial,Helvetica,sans-serif;
            }
        </style>
    </head>
    <body>
        <div class="header"><h1>DataTable demo (Server side) in Php,Mysql and Ajax </h1></div>
        <div class="container">
            <table id="employee-grid"  cellpadding="0" cellspacing="0" border="0" class="display" width="100%">
                    <thead>
                        <tr>
                            <th>Employee name</th>
                            <th>Employee name</th>
                        </tr>
                    </thead>
            </table>
        </div>
    </body>
</html>

How to load nested object array in DataTable

$
0
0

I have a json file that contains information and multiple recordsets (2 in this case). I'm trying to load them in individual datatable. I would like to load DMale DFemale in each a separate DataTable. My json file look looks like:

{
"event":[
   {
      "name":"test",
      "date":"Feb 11, 2018"
   }
],
"results":[
  {
     "Cat-D-Male":[
        {
         "Rank":"1",
         "Bib":"192",
         "First Name":"Kerry",
         "Last Name":"Reve",
         "Time":"01:01:28.445",
         "Gap":"",
         "Lap 1":"00:00:13.15",
         "Lap 2":"00:11:44.58",
         "Lap 3":"00:12:09.24",
         "Lap 4":"00:12:03.94",
         "Lap 5":"00:12:31.31",
         "Lap 6":"00:12:46.20"
        }
     ],
     "Cat-D-Female":[
        {
         "Rank":"1",
         "Bib":"178",
         "First Name":"Lisa",
         "Last Name":"Sax",
         "Time":"00:58:40.708",
         "Gap":"",
         "Lap 1":"00:00:14.89",
         "Lap 2":"00:11:49.55",
         "Lap 3":"00:11:29.52",
         "Lap 4":"00:11:21.15"
        },
        {
         "Rank":"2",
         "Bib":"325",
         "First Name":"Mellisa",
         "Last Name":"Sweet",
         "Time":"00:51:12.671",
         "Gap":"-1 Lap",
         "Lap 1":"00:00:17.52",
         "Lap 2":"00:12:56.86",
         "Lap 3":"00:12:23.24",
         "Lap 4":"00:12:54.41"
        }
     ]
  }
]
}

But I'm unable to extract DMale and DFemale to create the 2 DataTable. This is what I have so far:

<script>
  $( document ).ready( function( $ ) {
    $.ajax({
      type: "POST",
      url: 't4.json',
      cache: false,
      dataType: 'json',
      success: function(response) {
        $("#ResultsDiv").empty();
        $("#eventname").append(response.event[0].name);
        $("#eventdate").append(response.event[0].date);
        $("#eventlocation").append(response.event[0].location);
        console.log("1:" + response);
        var totalMessages = Object.keys(response.results[0]).length;
        console.log("2: Count= " + totalMessages);
        $.each(response.results[0], function(key, val) {
          console.log("3a:" + key);
          console.log("3b:" + val.length);
          console.log("3c:" + JSON.stringify(val));
          initiateTable(key, val);
        });
      }
    })

    function initiateTable(tableId, source) {
      $("#ResultsDiv").append('<table id="' + tableId + '" class="table table-striped table-condensed" cellspacing="0" width="100%"></table>');
      var table = $("#" + tableId).dataTable({
        "data": source,
        "bProcessing": true,
        "bPaginate": false,
        "bLengthChange": false,
        "bFilter": true,
        "bInfo": false,
        "bAutoWidth": true,
        "columnDefs": [{
          "targets": 'no-sort',
          "orderable": false
        }]
      });
    }
});
</script>

How can I pass each dataset to create a new DataTable and load the data and append it to the others tables in my div? I'm vey new at using JSon and DataTable, this is the fist time I use it.

Help to clear the Ajax window from my screen and help to understand your instructions

$
0
0

As said above, I need help to clear your Ajax warning window from my screen.
I cannot follow the instructions as my computer does not have the click places that are required.
Sincerely, Tui Scott (NZ)

Show/Hide fields and its associated json

$
0
0

I do not want to show a certain field created by a join. That is easy. I can easily do editor.field('merchant[].merchantID').hide() on the client side. There is still an issue however, in the console the data object still exists. Is there a way to not show that data? That should not be too difficult, I should be able to do something like this:

   $data = Editor::inst( $db, 'user', 'userID' )
   ->fields(...)
   ->join(
        Mjoin::inst( 'merchant' )
            ->link( 'user.userID', 'userMerchantLink.userID' )
            ->link( 'merchant.merchantID', 'userMerchantLink.merchantID' )
            ->order( 'name asc' )
            ->fields(
                Field::inst( 'merchantID' )
                    ->validator( 'Validate::required' )
                    ->options( Options::inst()
                        ->table( 'merchant' )
                        ->value( 'merchantID' )
                        ->label( 'name' )
                    ),
                Field::inst( 'name' )
            )
    );
$out = $data->process( $_POST )->data();
if(isset($_POST['action']) && $_POST['action'] !== "remove" ){
    // check if this is an admin then if not admin
    //1. do for loop and set each merchant.merchantID to empty array
   //2. set options object as an empty object
}

The only issue I now have is that when the user makes a post the merchant[].merchantID will be empty. I only wanted to hide the data not alter the data. So my question is how do I achieve this?

Filtering

$
0
0

I want to filtering by date in a single column not in range.But i'm unable for this please help me

Thanks

How use react with datatable editor

$
0
0

I can use react with datatables.
npm i jquery datatable.net

const $ = require('jquery');
$.DataTable = require( 'datatables.net' );

but I can't use editor,
npm i datatables.net-editor

import editor from 'datatables.net-editor';
or
require('datatables.net-editor');
always get error

how to use datatable editor with react
can you give a simple example?

Setting default value select when dynamically loading data

$
0
0

Hello,

For an inline form edit, I dynamically load data from a json query. I'll do the update with the update field.
Everything is working fine, but I want to set a selected field (default field).


$('#production_delivery_registrations').on('click', 'tbody td:not(:first-child)', function (e) { var tr = $(this).closest('tr'); var row = production_delivery_registrations.row( tr ); var index = production_delivery_registrations.column.index( 'fromVisible', $(this).index() ); var group_user = production_delivery_registrations.cell(this, production_delivery_registrations.column('group_user:name')).data(); var mx_order = production_delivery_registrations.cell(this, production_delivery_registrations.column('mx_order_description:name')).data(); switch(index) { case production_delivery_registrations.column('login:name').index(): case production_delivery_registrations.column('production_count:name').index(): case production_delivery_registrations.column('comment:name').index(): case production_delivery_registrations.column('production_date:name').index(): case production_delivery_registrations.column('production_run:name').index(): if ($('.production_delivery_registrations.show').data('rights_create') == 1) { production_delivery_registrations_modify.inline( this, { buttons: { label: '<em class="fa fa-edit"></em>', fn: function () { this.submit(); } } } ); } case production_delivery_registrations.column('production_run:name').index(): $.ajax({ url: Routes.order_references_order_event_list_path(mx_order, { format: 'json'}), type: 'GET', dataType: 'json', success: function(result) { production_delivery_registrations_modify.field('production_run').update(result); } }); }; });

The webform is

    production_delivery_registrations_modify = new $.fn.DataTable.Editor ({
        ajax: {
            edit: {
                url: $('#production_delivery_registrations').data('source'),
                type: 'PUT'
            }
        },
        table: '#production_delivery_registrations',
        idSrc: 'id',
        fields: [
            {
                name: 'production_date',
                type: 'datetime',
                def:   function () { return new Date(); },
                label: $('#production_date').html(),
            },{
                name: 'user_id',
                label: $('#login').html(),
                type: 'select',
            },
            {
                name: 'mx_order_description',
                label: $('#mx_order_description').html(),
                type: 'readonly',
            },
            {
                name: 'brand_description',
                label: $('#brand_description').html(),
                type: 'readonly',
            },
            {
                name: 'production_count',
                label: $('#production_count').html(),
            },
            {
                name: 'production_run',
                data: 'production_run',
                label: I18n.production_delivery_registrations.table.production_run,
                type: 'select'
            },
            {
                name: 'comment',
                label: $('#comment').html(),
            }
        ]
    });

When adding "def" to the table, the default value is not set, because the data is loaded afterwards
When adding production_delivery_registrations_modify.field('production_run').def(..); in the update, it also doesn't work.

Nice would be, to have a default parameter in the update string.

Regards,

Sander


How can I delete my account

$
0
0

Hello,

What is the procedure for deleting an account for datatables.net? Thank you.

Cheers,
Alex

How can I sort using a column with euro currency values?

$
0
0

I have a table with currency. I want to be able to sort it. The data has the euro sign symbol. I tried this:

<html>
<head>
    <script type="text/javascript"  src="js/jquery-3.1.1.min.js"></script>
    <script type="text/javascript"  src="js/jquery.dataTables.min.js"></script>
    <script type="text/javascript"  src="js/currency.js"></script>
</head>
<body>
<script>
$(document).ready(function() {
 var money_table=$('#moneys').DataTable();
 });
</script>

<table id="moneys">
<thead>
        <th>id</th>
        <th>chines</th>
</thead>
<tbody>
    <tr><td>0</td> <td>1.35 &euro;</td></tr>
    <tr><td>1</td> <td>15.65 &euro;</td></tr>
    <tr>    <td>2</td> <td>8.15 &euro;</td></tr>
    <tr>    <td>3</td> <td>1.00 &euro;</td></tr>
    <tr>    <td>4</td> <td>0.3 &euro;</td></tr>
</tbody>
</table>

</body>
</html>

But does not work. Any hint?

Paging Server Side Processing / XML

$
0
0

Hello there,

I have a problem which I can't figure out.

I'm using datatables server side processing to get data from a postgresql database. It works great but there is a problem with the pagination.

I display 25 row for each page, when i switch from page 1 to 2 there is no problem, but the count of all my data is 50, so I want the pagination to stop at 2 but datatable display page 3/4/5 which are empty.

So here is my question, how can I have the right pagination ?

Here is the code of my datatable creation :

dataTableElement = $('#tablename').DataTable({
        "serverSide": true,
        "info": false,
        "iDisplayLength": 25,
        "ajax" : {
            "url" : "/",
            "type" : "POST",
            "data" : {
                request : 'request',
                element : element,
                page : page,
                historicSearch : historicSearch,
                "source" : 'datatable'
            },
            "dataSrc" : "objects",
            "dataFilter" : XML2JSON
        },
        "language": {
            "lengthMenu": "Afficher _MENU_ éléments par page",
            "zeroRecords": "Aucun élément.",
            "infoEmpty": "Rien à afficher.",
            "search": "Rechercher : ",
            "paginate": {
              "previous": "Précédent",
              "next": "Suivant"
            },
        },
        "columnDefs": [
            {"name": "0", "targets": 0},
            {"name": "1", "targets":1},
            {"name": "2", "targets":2},
            {"name": "3", "targets":3},
            {"name": "4", "targets":4},
            {"name": "5", "targets": 5},
            {"name": "6", "targets": 6},
            {"name": "7", "targets": 7},
            {"name": "8", "targets": 8},
            {"name": "9", "targets": 9},
            {"name": "10", "targets": 10},
            {"name": "11", "targets": 11},
            {"name": "12", "targets": 12},
            {"name": "13", "targets": 13}
        ],
        conditionalPaging: true,
        "columns": [
            {data: "0", title: "0"},
            {data: "1", title: "1"},
            {data: "2", title: "2"},
            {data: "3", title: "3"},
            {data: "4", title: "4"},
            {data: "5", title: "5"},
            {data: "6", title: "6"},
            {data: "7", title: "7"},
            {data: "8", title: "8"},
            {data: "9", title: "9"},
            {data: "10", title: "10"},
            {data: "11", title: "11"},
            {data: "12", title: "12"},
            {data: "13", title: "13"}
        ],
        "order": [[ order, "asc" ]]
    });

I'm using XML to get the data which will be display like that :

<?xml version="1.0" encoding="utf-8"?>
<response>
    <header>
        <timestamp>2018-01-15 11:35:24</timestamp>
        <request>request</request>
        <element>element</element>
        <template>template</template>
        <datetime>15/01/2018 11:35:24</datetime>
        <exectime>0.035</exectime>
    </header>
    <data>
        <previousPage>previouspage</previousPage>
        <recordsTotal>2</recordsTotal>
        <objects pkey="id" total="2">
            <object id="1">
                <attr name="0">0</attr>
                <attr name="1">1</attr>
                <attr name="2">2</attr>
                <attr name="3">3</attr>
                <attr name="4">4</attr>
                <attr name="5">5</attr>
                <attr name="6">6</attr>
                <attr name="7">7</attr>
                <attr name="8">8</attr>
                <attr name="9">9</attr>
                <attr name="10">10</attr>
                <attr name="11">11</attr>
                <attr name="12">12</attr>
                <attr name="13">13</attr>
                <etatService>0</etatService>
            </object>
            <object id="3">
                <attr name="0">0</attr>
                <attr name="1">1</attr>
                <attr name="2">2</attr>
                <attr name="3">3</attr>
                <attr name="4">4</attr>
                <attr name="5">5</attr>
                <attr name="6">6</attr>
                <attr name="7">7</attr>
                <attr name="8">8</attr>
                <attr name="9">9</attr>
                <attr name="10">10</attr>
                <attr name="11">11</attr>
                <attr name="12">12</attr>
                <attr name="13">13</attr>
                <etatService>0</etatService>
            </object>
        </objects>
    </data>
</response>

The XML2JSON function transform XML into JSON, so I can get every parameters I want, like "recordsTotal" which I think is the key of the problem.

Here is the display of JSON I have :

{
   "recordsTotal":"2",
   "objects":[
      {
         "0":"0",
         "1":"1",
         "2":"2",
         "3":"3",
         "4":"4",
         "5":"5",
         "6":"6",
         "7":"7",
         "8":"8",
         "9":"9",
         "10":"10",
         "11":"11",
         "12":"12",
         "13":"13"
      },
      {
         "0":"0",
         "1":"1",
         "2":"2",
         "3":"3",
         "4":"4",
         "5":"5",
         "6":"6",
         "7":"7",
         "8":"8",
         "9":"9",
         "10":"10",
         "11":"11",
         "12":"12",
         "13":"13"
      }
   ]
}

So what can I do to have the right pagination in my page ?

Many regards,

Artens.

Absolute sorting does not work

$
0
0

I want to use absolute sorting such that columns with particular value is always seen on top.

JS Fiddle : https://jsfiddle.net/SujitJ/f73g0swn/

I would want all the entries with 'London' in 'Office' column to be seen on top.

How can I determine if a column is Searchable?

$
0
0

I'm using datatables.mark.js for highlighting the search in my datatables, but the plugin mark all columns including ones with searchable = false. I want to fix the plugin to mark only nodes inside columns with searchable = true.
Thanks in advance.

The code that mark the dt from the plugin:

            var globalSearch = this.instance.search();
            $(this.instance.table().body()).unmark(this.options);
            this.instance.columns({
                search: 'applied',
                page: 'current'
            }).nodes().each(function (nodes, colIndex) {
                var columnSearch = _this2.instance.column(colIndex).search(),
                    searchVal = columnSearch || globalSearch;
                if (searchVal) {
                    nodes.forEach(function (node) {
                        **$(node).mark**(searchVal,
                            // compatibilizar com a opção 'smart = false' do dataTable.Search
                            { "separateWordSearch": false });
                    });
                }
            });
Viewing all 81690 articles
Browse latest View live


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