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

How to render a particular column to have a link with it's data displayed and fetch row data

$
0
0

Hello,

I'm still new to Javascript, so any apologies if I missed anything. I have JSON data being passed to DataTables. Currently, I can click on a row to fetch all the data for that particular row. However, now I need to do almost the same thing but rather than click on the row, I'll need to render a specific column that still displays its data and have a link that will capture all the data for that particular row.

I've gotten the render to show "data" but I can't get it to show the data its suppose to show. For instance Case Number: "1234" should show "1234" but it shows "data". Then the link needs to be able to fetch that row's data.

Below is the current code I have:

// READY FUNCTION
$(document).ready(function() {
    var obj = $('#tempDataForm').serializeJSON();
    query('discrepancyList',obj,refreshDiscrepancyTable,0,"queryDiscrepancy.php");
});

function refreshDiscrepancyTable(response) {
    if(response.result.state == 'success') {
        var refreshedData = response.result.data.results;
        var colNames = response.result.data.colNames;

        if ( $.fn.DataTable.isDataTable('#discrepancyQueue') ) {
            $('#discrepancyQueue').DataTable().destroy();
        }

        $('#discrepancyQueue').DataTable( {
            data: refreshedData,
                    ``` // Allows row to be clicked to capture rows data
            "fnDrawCallback": function( oSettings ) {
                $('#discrepancyQueue').on( 'click', 'tr', function () {
                    var table = $('#discrepancyQueue').DataTable();
                    // Gets the row values
                    var rawData = table.row( this ).data();
                    var data = (JSON.stringify(rawData));
                });
            },```
            columns: colNames,
            responsive: true,
            // Hides "Id" columns and makes it not searchable
            "columnDefs": [
                {
                    "targets":  [ 0 ],
                    "visible": false,
                    "searchable": false
                },
                ```{
                    "targets": [ 1 ],
                    "data": "Case Number",
                    "render": function ( data, type, row, meta ) {
                    return '<a href="'+data+'">data</a>';
                    }
                } ```
            ]
        });

        var myTable = $('#discrepancyQueue').DataTable();
        notify('success','Test!');
    } else {
        notify('warn','Error!');
    }
}

Any help on this would be greatly appreciated.


SSP class server-side ORDER BY

quickler

$
0
0

does not show the updated records when adding a new record I use in boostrap 4

scroller extension / server side processing - data jumps after reloading

$
0
0

I am trying to use the scroller with server side processing, but the scroll position appears to jump every time new data is loaded.

It can be seen in the example given here https://datatables.net/extensions/scroller/examples/initialisation/server-side_processing.html

If I scroll slowly, new data records are requested when record #46 comes into view, but it scrolls back to view record #23.
If I continue scrolling slowly, every time new data is loaded it jumps either forward or backward in the table.

Is there any way I can fix this?

Creating an attendance register report

$
0
0

I want to create an attendance register report that looks like this:

The information above the dates is the lesson for that day.

The JSON being returned to the jQuery is:

[{"attId":"120","cdId":"MTQ5","attMeeting":"A","attDate":"2019-01-11","cdSurname":"Achilles","cdFirstName":"Tendon","attDescription":"Cycling","attNewChum":"N"},{"cdId":"ODA=","cdSurname":"Alistair","cdFirstName":"Tricia","attDescription":"Running","attNewChum":"N"},{"cdId":"MTQ5","cdSurname":"Achilles","cdFirstName":"Tendon","attDescription":"Cycling","attNewChum":"N"},{"attId":"121","cdId":"ODA=","attMeeting":"P","attDate":"2019-01-12","cdSurname":"Alistair","cdFirstName":"Tricia","attNewChum":"N"},{"attId":"122","cdId":"MTQ5","attMeeting":"P","attDate":"2019-01-13","cdSurname":"Achilles","cdFirstName":"Tendon","attDescription":"Rowing","attNewChum":"N"},{"attId":"123","cdId":"ODA=","attMeeting":"P","attDate":"2019-01-13","cdSurname":"Alistair","cdFirstName":"Tricia","attDescription":"Rowing","attNewChum":"N"}]

The mySQL that extracts the data has a Left Join so all the names are extracted if there is a date (i.e., you can have a name followed by all columns having blanks).

Is it possible to do this?

Kind regards,

Glyn

Is the read only display field type editor plugin dynamic for EVERY row?.

How to disable incremental filter

$
0
0

I am using Datatables.Net v1.10 and I am using an external data source via an API and ajax within the datatable. I would think that in a serverside scenario, incremental search would be disabled by default. However, I really need to disable it and have the filter be performed after the user hits enter or add a Go button to the filter box, as my data sets tend to be very large. How can I achieve this?

Manually trigger change event on editor field

$
0
0

I want to manually trigger change event on an editor field so that the logic in

editor.dependent("", )...

Logic is re-executed.

Is it possible ?? how can I do that ?


How add an image in a messageBottom?

$
0
0

I´m trying to add an image like an e-signature under the table but it doesn´t work.

this is my code:

buttons: [
            {
                extend: 'pdf',
                pageSize: 'LEGAL',
                title: 'Comprobante de pedido',
                text: 'Exportar en PDF',
                filename: `Jireh PC Pedido No. `+numPed+``,
                messageBottom: {
                  lineHeight: 5,
                  text: '\n Autorizado por: \n',
                  customize: function ( doc ) {
                    doc.content.splice( {
                      margin: [ 0, 0, 0, 12 ],
                      alignment: 'center',
                      image: `data:image/png;base64,.............`
                    });
                  },
                  alignment: 'center',
                  margin: [ 0, 0, 0, 12 ],
                },
                customize: function ( doc ) {
                // Splice the image in after the header, but before the table
                doc.content.splice( 1, 0, {
                    margin: [ 0, 0, 0, 12 ],
                    alignment: 'center',
                    image: `data:image/png;base64,.........`
                } );
                // Data URL generated by http://dataurl.net/#dataurlmaker
            }
            },
        ]
  });

$('#example').DataTable().column(4).data().sum(); returning 0

$
0
0

Sample case: https://datatables-ecommerence.000webhostapp.com/
I have no errors on the console or w3validator.

` <script src="https://cdn.datatables.net/plug-ins/1.10.19/api/sum().js"></script>`
    $(document).ready(function() {
      var sum = $('#example2').DataTable().column(4).data().sum();
      $('#total').html(sum);
    });

I tried other columns too and they all return 0.

=====

Since I have two tables, I may have to make my own personal script because https://cdn.datatables.net/plug-ins/1.10.19/api/sum().js uses example (not example2). That is the only thing I can think of that could be wrong.

I will post any other updates as I will be working on this for a while.

trying to select first two colums from table on select

$
0
0

So I am currently getting the first column's data which are selected from my datatable

let rows = table.rows( { selected: true } );
var result = table.cells( rows.nodes(), 0 ).data();
delete result["context"];
delete result["length"];
delete result["selector"];
delete result["ajax"];

But I'd like to get the first two columns of data in the table.

Editor datetime get(set)Formatter issue node.js oracle

$
0
0

here's the complete server side endpoint:


let db = require('../db'); let router = require('express').Router(); let moment = require('moment'); let clientFrmt = "M/D/YYYY h:mm a"; // let dbFrmt = "YYYY-MMM-DD"; let dbFrmt = "YYYY-MMM-DD HH:mm:ss.SS"; let { Editor, Field, Validate } = require("datatables.net-editor-server"); router.all('/dtables/inout/:EMPNO', async function (req, res) { let editor = new Editor(db, 'IN_OUT', 'IDNO') .fields( new Field('IO_DATE').validator(Validate.notEmpty()) .getFormatter((val, data)=>{return moment(val).format(clientFrmt)}) .setFormatter((val, data)=>{return moment(val).format(dbFrmt)}), new Field('ORIG_IO_DATE').validator(Validate.notEmpty()) .getFormatter((val, data)=>{return moment(val).format(clientFrmt)}) .setFormatter((val, data)=>{return moment(val).format(dbFrmt)}), new Field('STATUS').validator(Validate.notEmpty()), new Field('CMNTS') ) .where('EMPNO', req.params.EMPNO) .where('ORIG_IO_DATE', '>', moment() .subtract(3, 'weeks') .format('DD-MMM-YY') // had to do the date this way, in order to comply with nls database/oracle standard .toUpperCase()); await editor.process(req.body); res.json(editor.data()); }); module.exports = router;

If I change dbFrmt to 'YYYY-MMM-DD' it works, but sets the time to midnight (expected).
But I want to be including time information in my updates. So when I set dbFrmt to 'YYYY-MMM-DD HH:mm:ss.SS' I get the following error:


Unhandled promise error: [object Promise]Error: update IN_OUT set IO_DATE = :1 where IDNO = :2 - ORA-01861: literal does not match format string stack: Error: ORA-01861: literal does not match format string

Please anyone help? I know i'm most likely doing something very small and silly in error.

How to inherit the width of columns in printing?

$
0
0

I have set the width of the columns for my datatable but when I use the print button, the columns were set with auto-width again.

How to fix Cannot read property 'DT_RowId' of null?

$
0
0

Here is my html code
<div class="card"> <div class="card-content"> <div class="row"> <div class="col-md-12"> <div class="fresh-datatables"> <table id="datatables" class="table table-no-bordered table-hover table-style" style="width:100%"> <thead> <tr> <th>Plate No.</th> <th>Model</th> <th>Brand</th> <th>Description</th> <th>Driver</th> </tr> </thead> </table </div><br> </div> </div> </div> </div>

Here is my js code
<script> $(function () { $("#datatables").DataTable({ "bLengthChange": false, "ajax": "vehicleListing.json", "aoColumns": [ {"mData": "plateNo","defaultContent": " "}, {"mData": "model","defaultContent": " "}, {"mData": "brand","defaultContent": " "}, {"mData": "description","defaultContent": " "}, {"mData": "driver","defaultContent": " "}] }); }); </script>

Here is my data
```{"aaData":[{"plateNo":"AF8003","model":"2009","brand":"HONDA","description":"HONDA XR","driver":"Edward Lumines"},{"plateNo":"ZRE851","model":"2009","brand":"STAREX","description":"STAREX GOLD","driver":"Edwin Besmonte"},{"plateNo":"ZTH551","model":"2009","brand":"TOYOTA","description":"HI LUX D4D 4X4","driver":"P. ASPILLAN"},{"plateNo":"AF6658","model":"2008","brand":"HONDA","description":"HONDA XR200","driver":"Rodolfo Balag-ey"},{"plateNo":"ZTH491","model":"2009","brand":"TOYOTA","description":"HI LUX D4D 4X4","driver":"M.A.AMISOLA"},{"plateNo":"ZTH531","model":"2009","brand":"TOYOTA","description":"INNOVA","driver":"AMY LYN TIMPAC"},{"plateNo":"ZTH521","model":"2009 INNOVA","brand":"TOYOTA","description":"INNOVA - GAS","driver":"B. BAJO"},{"plateNo":"ZTH511","model":"2009","brand":"TOYOTA","description":"INNOVA","driver":"GILBERT GUIAMOY"},{"plateNo":"ZTH501","model":"2009","brand":"TOYOTA","description":"INNOVA","driver":"E.LUMINES"},{"plateNo":"AF7851","model":"2009","brand":"HONDA","description":"XR200","driver":"Danilo Banda-ay Jr."},{"plateNo":"AHD752","model":"2002","brand":"ISUZU","description":"TELELECT","driver":null},{"plateNo":"AHD762","model":"2002","brand":"ISUZU","description":"TELELECT","driver":"Joel Esteban"},{"plateNo":"AHD772","model":"2002","brand":"ISUZU","description":"TELELECT","driver":"OMD"},{"plateNo":"ZPU686","model":"2009 K2700","brand":"KIA CERES","description":"KIA 2700","driver":"F. DAMIAN"},{"plateNo":"AHD792","model":"2002","brand":"ISUZU","description":"TELELECT","driver":"NSAD"},{"plateNo":"AF7977","model":"2010","brand":"HONDA","description":"CBR150","driver":"Paul Donaal"},{"plateNo":"NIY932","model":"2010","brand":"KIA CERES","description":"KIA 2700","driver":null},{"plateNo":"NIY942","model":"2010","brand":"KIA CERES","description":"KIA 2700","driver":"Moreno Awingan"},{"plateNo":"WRX372","model":"2001","brand":"SUZUKI","description":"SUZUKI SAMURAI","driver":null},{"plateNo":"WFC681","model":"1999","brand":"ISUZU","description":"BASKET TRUCK","driver":"MOTORPOOL"},{"plateNo":"NIN361","model":"2010","brand":"KIA CERES","description":"KIA 2700","driver":null},{"plateNo":"NIG881","model":"2010","brand":"KIA CERES","description":"KIA 2700","driver":null},{"plateNo":"NIW631","model":"2010","brand":"KIA CERES","description":"KIA 2700","driver":null},{"plateNo":"NIG992","model":"2010","brand":"KIA CERES","description":"KIA 2700","driver":null}]}

Here is the error
jquery.datatables.js:19 Uncaught TypeError: Cannot read property 'DT_RowId' of null
at Object.rowIdFn (jquery.datatables.js:19)
at O (jquery.datatables.js:16)
at jquery.datatables.js:49
at i (jquery.datatables.js:35)
at Object.success (jquery.datatables.js:36)
at i (jquery-3.1.1.min.js:2)
at Object.fireWith [as resolveWith] (jquery-3.1.1.min.js:2)
at A (jquery-3.1.1.min.js:4)
at XMLHttpRequest.<anonymous> (jquery-3.1.1.min.js:4)

How does I can increase the height of the datatable

$
0
0

Currently I am using the data table to view the employee stattus. I want to increase the height of the datatable to accommodate maximum 35 rows employee details. I want to make it fixed height data table in bootstrap . At the moment it only support 16 rows. I want to increase little bit more in bootstrap .Please can you help
I have attached my code below


Resize and ReOrder column with column search and fixed column

$
0
0

Hello Sir/Madam,

Kindly give example of Resize and Reorder column works with functionality (individual Column search and Fixed column).

I have already found example of (individual Column search and Fixed column) at
http://live.datatables.net/diwapewa/1/edit.

I want Features Resize and Reorder column with this above example.

Waiting for response.

Individual column search is not working with Horizontal scroll on (scrollX = true) at a time

$
0
0

I have table created column dynamically and bind JSON data to it using Jquery. Implement coumn search on Document.Ready function and column search working fine. but when I set scrollX= true to implement horizontal scroll and fixcolumn then horizontal scroll apply to table but column search stop working with it.

Can you guide me how to work together column search and horizontal scrollbar and fixcolumn together..

sample code

Column search

  $j('#tblMasterList tfoot th').each(function () {
        var title = $j(this).text();
        $j(this).html('<input type="text" placeholder="Search ' + title + '" />');
    });

    // DataTable
    var table = $j('#tblMasterList').DataTable();
   
    // Apply the search
    table.columns().every(function () {
        var that = this;

        $j('input', this.footer()).on('keyup change', function () {
            debugger;
            if (that.search() !== this.value) {
                that
                    .search(this.value)
                    .draw();
            }
        });
    });

    var r = $j('#tblMasterList tfoot tr');
    r.find('th').each(function () {
        $j(this).css('padding', 8);
    });
    $j('#tblMasterList thead').append(r);
    $j('#search_0').css('text-align', 'center');

DataTable binding with columns and JsonData

  $j('#tblMasterList').DataTable({
       
        data: jsondata,
        columns: vCols,
        scrollX: true
       
    });

how to change lengthMenu of 2 tables at the same time

$
0
0

Hello ,
i have two tables on the same Display with different column names . i want to change both lengthMenu at the same time .
Thanks

DataTables Editor DataTime Picker OnChange Event has no data.

$
0
0

Hello, regarding new $.fn.DataTable.Editor.DateTime() I noticed that the selected date is actually a property on the instance.

This is making some plugin development pretty difficult for us. The OnChange event has no arguments so we can not properly set up hoods with the Editor DateTime Field.

Can you please pass the selected date back when you internally call OnChange?

Group datatable by multiple colum

Viewing all 81402 articles
Browse latest View live


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