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

Customize render callback to not expect a string and just perform actions within the callback fn

$
0
0

Link to test case:
https://github.com/DataTables/ColReorder/issues/49

Current versions of packages installed:
"datatables.net-dt": "^1.11.3",
"datatables.net-colreorder-bs4": "^1.5.5",

Description of problem:

In reorder of columns using ColReorder, it was unable to trigger the dynamic insertion of components done in createdCell callback due to render being run.

Hence, the workaround I found was to trigger the same createdCell callbackfn in the return of renderFn.

I have raised a PR for the same https://github.com/DataTables/DataTablesSrc/pull/198

The usage sample is as below

col.renderReturnType = 'function'; // only then will these changes be activated

const createdCellCallback = (tdElm, cellData, rowData, rowIndex) => {
  // dynamically insert an angular component into tdElm with help of Renderer2; passing in needed values from rowData and cellData as @Inputs to the component
}

col.render = (data, type, row, meta) => { return createdCellCallback; }

col.createdCell = createCellCallback;

Please check and merge this at the earliest, in a matter of hours to be exact.


Suggestion: WP themes for dattables

$
0
0

Hi all,

Can anyone please a good WP theme that goes well with Datatables?

Thank you

How would I change the color and text of the searchbuilder filter button when a filter is applied?

Problem with the where condition which is not taken into account

$
0
0

Hello,

I have a problem with this code which runs fine but the conditions where not taken into account.
I tried multiple solutions. Always the same result.

product.supp is INT
product.archive is INT
I want to exclude all rows that are 1 for either

<?php
// DataTables PHP library
include( "../Editor-PHP-1.9.1/lib/DataTables.php" );

// Alias Editor classes so they are easy to use
use
    DataTables\Editor,
    DataTables\Editor\Field,
    DataTables\Editor\Format,
    DataTables\Editor\Mjoin,
    DataTables\Editor\Options,
    DataTables\Editor\Upload,
    DataTables\Editor\Validate,
    DataTables\Editor\ValidateOptions;
    
    
    
Editor::inst( $db, 'produit_prix' )
    ->field(
        Field::inst( 'produit_prix.produit_id' )
            ->options( Options::inst()
                ->table( 'produit' )
                ->value( 'id' )
                ->label( 'produit' )
            )
            ->validator( Validate::dbValues() ),
        Field::inst( 'produit_prix.prix' ),
        Field::inst( 'produit_prix.saison' ),
        Field::inst( 'produit_prix.last_update')
          ->setValue( date('c') )
          ->getFormatter( 'Format::date_sql_to_format', 'jS F Y' ),
        Field::inst( 'produit.produit' ),
        Field::inst( 'produit.supp' ),
        Field::inst( 'produit.archive' )
    )
    ->leftJoin('produit', 'produit.id', '=', 'produit_prix.produit_id')
    ->where('produit.supp', '1', '!=' )
    ->where('produit.archive', '1', '!=' )
    ->process($_POST)
    ->json();

Print Not working working in Electron js app

$
0
0

Only white popup window showing while press print button from data table in Electron Application.
screen short attached for your reference.

Not showing other button like, pdf / csv / excel button

i am new in data table. can any body help me to find solution

My script as given below
var $ = require( 'jquery' );
var dt = require( 'datatables.net' )();
require( 'datatables.net-buttons/js/buttons.colVis.js' )(); //# Column visibility
require( 'datatables.net-buttons/js/buttons.html5.js' )(); //# HTML 5 file export
require( 'datatables.net-buttons/js/buttons.print.js' )(); //# Print view butto

$(document).ready( function () {

        var table = $('#table_id').DataTable({
          "dom": '<"toolbar">Bfrtip',
          "language": {
            "paginate": {
              "next": "Next"
            }


          },
           buttons: [
            'copy', 'csv', 'excel', 'pdf', 'print'

    ]

        })

        $("div.toolbar").html('<input class="datePicker" type="month" name="" id="dated">');
      dated.onchange = evt =>{
        table.draw();

      }
        $.fn.dataTable.ext.search.push(
          function(settings, data, dataIndex) {
            var sdate =  $('#dated').val().split('-')
            var month = sdate[1]
            var year = sdate[0]
          console.log(data)
            var date = data[1].split('-');
            if ((isNaN(year) && isNaN(month)) ||
              (isNaN(month) && year == date[0]) ||
              (date[1] == month && isNaN(year)) ||
              (date[1] == month && year == date[0])
            ) {
              return true;
            }
            return false;
          }
        );
      });

How to format editor field number into comma separated on change or dependent without using mask?

$
0
0

Link to test case:
Debugger code (debug.datatables.net):
Error messages shown:
Description of problem:

Dynamic creation of footer through columns definition.

$
0
0

I have a table where the table headers are created using the column definitions columns.title rather than the DOM

https://datatables.net/reference/option/columns.title

Is there way to define the footer through columns eg. something like columns.footer, or an option to automatically copy header to footer.

I've looked through the docs and can't see anything obvious

Thanks in advance,
Adrian

No Select on SearchPanes, when loadling language.json thru url

$
0
0

see test: http://live.datatables.net/suqirihi/1/edit

When adding

                language: {
                    url:  "http://cdn.datatables.net/plug-ins/1.11.4/i18n/de_de.json"
                }

to a SearchPanes Table, it is not possible to click the filter values. Removing the URL or even putting the json String inside language solves the problem as workaround.

initialization:

$(document).ready( function () {
            table = $('#example').DataTable({
                dom: 'Pfrtip',
                language: {
                    url:  "http://cdn.datatables.net/plug-ins/1.11.4/i18n/de_de.json"
                }
            });
} );

Edited by Colin - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.


Speed issue when using inline editing with checkboxes

$
0
0

Hi,

I've noticed that when using inline editing with checkboxes the speed of the page load and any CRUD actions are taking considerably longer than without inline editing.

Below are two test cases, these are identical except the first URL is using inline editing for all of the checkboxes.

Test URL 1: https://wd4g.com/WCGateway/DTTest.wc
Test URL 2: https://wd4g.com/WCGateway/DTTest2.wc

They both use the same Ajax source for init and CRUD actions, so I suspect it is something to do with the rendering of the checkboxes, but I'm struggling to find the cause of this, could someone please take a look?

A quick test to see the speed difference is to hit the reload table data button

Thanks, Chris

table header does not automatically adjust to textarea inside td changing

$
0
0

Link to test case:
Debugger code (debug.datatables.net):
Error messages shown:
Description of problem:

Please watch my gif on https://imgur.com/QPtycqD

I have textareas inside tds. Adjusting the textarea does not automatically adjust the th.

It does however automatically adjust upon window.resize(). You can see this as I quickly open and close Dev Tools.

https://datatables.net/reference/api/columns.adjust() states that "DataTables will automatically call this method on the window resize event to keep the columns in sync with the re-flowed layout." . I tried calling columns.adjust() on a textarea.mouseup event but had weird results with this.

I can't come up with a simple reprex for this unfortunately. And so I was wondering if anybody else has dealt with this and can offer a solution. Thanks!

Note: I'm also using Bootstrap 4.

table-bordered table-condensed compact display nowrap are the classes I've applied to the DT instance

Unable to automatically determine field when column renders custom buttons only

$
0
0

Link to test case:
http://live.datatables.net/hovopoce/1/edit

Error messages shown:
Uncaught Unable to automatically determine field from source. Please specify the field name. For more information, please refer to https://datatables.net/tn/11

Description of problem:
When I move from cell to cell pressing the tab key, as I reach the last column (which renders only 2 buttons, no data reading from data array) , the error above appears. I ve tried removing the obj of that column from the editor.fields , but didn't work.
This error prevents the 'click' events (defined in the datatable) to be assigned to the buttons.

How can i render custom buttons in a columns that isn't related to any data and keep the tab feature to move from 1 cell to another?
How can i add 1 new empty line when i press tab on the last cell of the last row (excluding the column with btns)?

Thanks in advance for the help!

Datatable Checkbox regex

$
0
0

Im using this code as an example of what i want to do:http://live.datatables.net/rosahuka/1/edit
The diference its that i want to filter the checkbox like for weeks, for example i want a checkbox that says This week and that the value is 2009/01/12|2012/12/02|2012/03/29, i have already see this example regex to use the | to write in between values and it works fine, but i have not succefully use that on a checkbox value, i know that there is a tool that filter date ranges with a input that displays a calendar, but i do not need that, i need a checkbox called "this week" and assign it a this value 2009/01/12|2012/12/02|2012/03/29 so the datatable show me the three values dates

TinyMCE not loading content in Editor

$
0
0

I have an Editor table that is making use of the TinyMCE plugin for one of the fields. Works without issues using packages:

"datatables.net": "^1.10.19",
"datatables.net-bs4": "^1.10.19",

However, upon the upgrade to packages:

"datatables.net": "1.11.4", or 1.13.9
"datatables.net-bs4": "1.11.4",

the TinyMCE content field will no longer load the contents. It simply displays blank. I've experimented with a variety of things to debug and found that the package update is the culprit. The first time I edit a record in a private/incognito browser there is a quick flash of the content and then it gets cleared out. Any assistance in resolving this or an update to the TinyMCE JS to fix would be appreciated.

Thanks

browser compatibility

$
0
0
function formatc ( table ) {
    // video hide compilations checkbox
    var state;
    if (table.state.loaded() === null) {
        state = '';
    } else {
        try {
            state = table.state.loaded()['columns'][COLUMN3]['search']['search'];
        } catch (error) {
            state = '';
        }
    }
    return '<input type="checkbox" id="covdcb" value="hide"'+
            (state === 'hide compilation' ? ' checked' : '')+
            '>Hide Compilations</input>';
}
$(document).ready(function() {
    var table = $('#covd').DataTable( {
        "processing": true,
        "serverSide": true,
        "dom": "<'tbh'l<'compilations'>f>rtip",
        'deferLoading': (coepvd === 'v' ? null : 0),
        "stateSave": true,
        "stateDuration": -1,
        "stateLoadParams": function (settings, data) {
            data.search.search = "";
            },
        "ajax": { "url": "/covd.php",
            "data": function (d) {
                d.CompanyID = companyID;
                }
            },
        "pagingType": "input",
        "order": [[COLUMN0, 'desc']],
        "search": { "return": true },
        "lengthMenu": [ 25, 50, 100 ]
    } );
    // recompute column widths on search
    table.on( 'search.dt', function () {
        table.columns.adjust();
    } );
    // recompute column widths on sort
    table.on( 'order.dt', function () {
        table.columns.adjust();
    } );
    $("div.compilations").html(formatc(table));
    $(document).ready(function() {
        $("#covdcb").change(function() {
            var table = $('#covd').DataTable();
            if ($(this).is(':checked')) {
                table.columns(COLUMN3).search('hide compilation').draw();
            } else {
                table.columns(COLUMN3).search('show compilation').draw();
            }
        });
    });
} );

I have users using unpredictable browsers that I can't test with.
One is using Safari 9 and can't get a search to work.
I use: "search": { "return": true }

Is there any experience with the enter key not working for a search on old browsers?
Catching an enter key seems rather rudimentary.
The user can see the Javascript errors and none show up.

Sorry, I can't share the website so I expect any help here will be pure luck.
I am a little worried that I may have gotten myself into a bind with older browsers.

I was going to experiment with removing the webkit search cancel but that was supported in Safari 3!

Edited by Colin - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.

How to sum values in row groups and display calculated values in a column

$
0
0

http://live.datatables.net/topuhayo/1/edit

I have created "row groups" by using the orderFixed attribute in the datatables initialization (in the example linked I am creating row grouping using the office location values).

I am trying to then sum values in these groups using drawCallback (in this example I am summing the salary values). I then want to display the resulting sum in the empty column so that the summation of salaries for that group can be visible. The reason I am not using RowGroup or something similar is because I want to show these summation values in generated reports (csv, excel, pdf) but the RowGroup values are not exported.

My issue is that I am having trouble figuring out how to put the sum of a row groups salary into the empty column, and I don't know how to handle the case where a row group is spread over multiple pages (I don't want to sum over current page, I want to sum all values for that group)

Any help would be appreciated thank you


Feature conflict - ellipsize / invalidate

$
0
0

I have fairly complex table where every cell is editable. Some cells are dependant on others, ie a single cell edit may affect multiple cells within a row. Edit is done with jeditable, and jquery is used to update to the dom. After this I use row.invalidate() to update DataTables internals with the changes.

One of the table columns is a textarea, so there is an ellipsize function (similar to the plugin offered here) to present a shortened string when not editing. This is called in render (type display). As the string is editable, this returns an HTML snippet (anchor etc) - so it is modifying the dom.

The issue I'm hitting is that row.invalidate() is reading the ellipsized string in the dom and storing it internally, ie the full-text version of the string is overwritten. A subsequent edit renders the ellipsized string in the edit form.

What is the correct way to handle this?

Why Can I Not Show More Than 8 Columns Using Server-Side with .Net

$
0
0

I have multiple DataTables using Server Side processing in a .Net website and I cannot get any of them to display more than eight (8) columns. In all cases, the ajax data contains more than 8 columns, and I can switch any of the DataTables columns successfully to any of the data columns returned from the server -- as long as I do not try to display more than 8.

When I do try to display more than 8 columns, I always receive the same error message back from DataTables and the ajax call to the MVC controller providing the data never executes (debug breakpoints do not occur). The error message I am receiving back is shown in

A screen capture of a successful 8-column display is provided in:

A screen capture of a failed 9-column display is provided in:

When the error message shown in the picture above is displayed, I am also receiving a console error in Chrome's developer tools and the picture of that message is:

All I have to do to re-create the problem is to add the 9th "data" item to the "ajax columns" entries and add a 9th column header to the html table definition <thead> list.

I attempted to attach a file containing the source code for the DataTables instance but the Attach A File link kept saying no file selected.

I tried to run the DataTables debugger but it appeared to fail while uploading. The screen capture from that is shown in:

and the error messages in the Chrome console log are shown in:

That's the best I can do to present the information about the failure I am receiving. I do not have a method available at this time to provide real-time execution access to this webpage.

As an additional note: The DataTable(s) is(are) running on Webform pages and the ajax url's are to MVC Controllers. I use Debug breakpoints to catch the MVC controller(s) during execution, but when I receive the error the MVC Controllers never execute. Execution appears to stop before the MVC Controllers are ever called.

Link to test case:
Debugger code (debug.datatables.net):
Error messages shown:
Description of problem:

How to limit image downloads in datatables?

$
0
0

I have PHP/MySQL and Datatables handling 1500 rows of data. Part of this data is the path to images that I display on the web page. As our number of rows increased, we started having problems with the server running out of memory. Now, we see using the browser dev tools, that even though the web page is displaying only 10 records, it is downloading all 1500 images! How can I only have datatables download the number of images being requested? Thank you for any help.

what is the best css framework for jquery datatable ?

$
0
0

what is the best css framework for jQuery datatable ? At present Bootstrap, Foundation, Tailwind, Materialize, Bulma etc. lots of css framework are using for web development, so my question is that which framework will be best fit for datatable> (col-reorder, fixed column, sorting, pagination, accessibility those feature also need)

Please suggest.

Thanks
SD

Can we avoid multiple searchBuilder server call without upgrade nightly version

$
0
0

Any solution to avoid multiple server call issue for searchBuilder in current version(1.1.0) without upgrading to nightly build.

Viewing all 82294 articles
Browse latest View live


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