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

Server side editor, add custom field

$
0
0

because i cant make left join to table with composite keys, how can i bring extra data for each row from this table and send it in the editor response?


Column-Filter with FixedColumns and ScrollResize

$
0
0

Hello,
i have a table that uses fixed column, scrollResize and individual column filters.
My problem is, that if i enter a value into the input of the fixed column (column #1), the search is triggered once i typed the first letter and the input field gets cleared.
After a lot of testing i found out, that this issue is caused by the option "scrollResize: true", which activates the ScrollResize-Plugin.

Any idea how i can solve this?

http://live.datatables.net/fologejo/3/edit

Display field errors in toastr

$
0
0

Hi

I am trying to "catch" the field errors from datatables editor json response to display these errors in a toast (toastr.js) as my custom form uses steps and moving to the next step closes the previous step, thus hiding the error div and we are using PHP validation, not client-side...

          editor.on( 'initSubmit', function (e, action) {
        if ( editor.inError() ) {
            toastr.error(editor.error(e));
            return false;
        }
    });

I have successfully managed to display toasts for edit, remove and create, (see example below) but the same approach does not seem to work for errors.

    editor.on('submitSuccess', function ( e, json, data, action ) {

        if (action === 'create') {
            if (json.error) {
                console.log('got create error '+json.error)

            } else {
                toastr.success("Nuwe Lid gestoor!");
            }
         }
    });

I have tried initSubmit, open, submitError etc. with no luck. Another option would be to display the error in the form footer, but again, we would have to assign the error to a variable.

How to update "data" of an already initialized DataTable object?

$
0
0

I have code

var dtParams = {
    "serverSide": true,
    "ajax": {
        "url": "load_items",
        "data": function ( d ) {
            d.extra_data = "old value";
        }
    },
};
var table = $('#main_listing_table').DataTable(dtParams);

Now once table is loaded, I want to modify or add more parameters that "extra_data" without destroying previous object

I tried

//this does not work
table.ajax.data = function (d) {
    d.extra_data = 'new value';
};
//this does not work
table.data('dt_params', {name: 'extra_data': 'new value'});

I can see Network tab its always sending "old value"

why the table does not display data that comes from the server?

$
0
0

My test case is:http://montaj.vianor-konakovo.ru/orders.html?id=16.If you select a row with code 100 in the first column in the first table, the server will return 2 rows for the second table, but they are not displayed and an error occurs. Explain what the problem is. What do I need to change for the program to work correctly?

jQuery DataTable with Server-Side processing using .NET Core 2.2

PDF Button extend options -- messageTop not working with doc.content[1].table.widths

$
0
0

Hi,

I'm trying to extend pdfHtml5 to include a top message and set column widths. Example code is here:

https://jsfiddle.net/mtilton/j20L7soe/

However, the page just hangs when the user clicks on the PDF button. Strangely, messageBottom works fine. The code also works when the doc.content[1].table.widths line is removed -- but I need this.

In the actual code I'm running, I use a local copy of datatables 1.10.18 and buttons 1.5.4. Clicking on the PDF button with messageBottom works, but messageTop generates a javascript error:

"Uncaught TypeError: Cannot set property 'widths' of undefined
at Object.customize
at s.action (buttons.html5.min.js:35)
at v (dataTables.buttons.min.js:16)
at HTMLButtonElement.<anonymous> (dataTables.buttons.min.js:17)
at HTMLButtonElement.dispatch (jquery.min.js:4)
at HTMLButtonElement.r.handle (jquery.min.js:4)"

Thanks for any suggestions.

Meg

Access to specific datatable attribute

$
0
0

Hello everybody,
How i can get this attribute


How to keep return carriage (\r\n ) in the table column.

$
0
0

http://live.datatables.net/vegayade/1/edit?html,js,output

var dt = [
{"ABC":"111111111","NAME":"NAVY PIER \r\nDANCE CLUB\r\nRT 12 BLDG 007","ADDRESS":"NAVY PIER BLDG 425\r\nSUBMARINE HOUSE BOX 21\r\nCHICAGO IL 06340","MRY":"1980"},
{"ABC":"222222222","NAME":"BAR ONE\r\nDRINKS","ADDRESS":"123 N WELLWOOD AVE\r\nLINDENHURST NY 22222","MRY":"1957,1958"},
{"ABC":"333333333","NAME":"SEARS","ADDRESS":"505 STEWART AV \r\nGARDEN CITY NY 55555","MRY":"1961,1962,1963,1964"}
];

Specify Column Data via HTML data attributes?

$
0
0

In my initiailzation I have columns defined to match my AJAX JSON data as follows (example):

    columns: [
      { data: "column1" },
      { data: "column2" },
      { data: "column3" }
      ]

Is there a way to avoid this and define this from the view via html data attributes like this?:

          <table id="my_datatable" data-source="my_data.json">
            <thead>
              <tr>
                <th data-column="column1">Column 1</th>
                <th data-column="column2">Column 2</th>
                <th data-column="column3">Column 3</th>
              </tr>
            </thead>
            <tbody>
            </tbody>
          </table>

Is is possible to have only specific columns displayed in responsive mode?

$
0
0

My thought here is to keep a consistent UI and have the tables collapse an leave only the first column in responsive mode regardless of the width - i.e. as soon as the responsive mode is triggered you only get the one column.

Can you do that?

Replace search function entirely, not just $.fn.dataTable.ext.search.push

$
0
0

We have set the searching parameter to true and it works as expected.

However we want to cusomise the search function, depending on what is entered we would like to show and hide different rows and it is a bit more advanced than just searching the data for a string.

Now we have seen the $.fn.dataTable.ext.search.push function. It adds additional filtering. We would however like to replace the entire filtering function if possible so that we can get full control.

Is it possible to keep the search field, but replace the function used for filtering?

AJAX call with nested JSON Data

$
0
0

I have a json source that I'd like to use inside a DataTable:

{
  "tickets" : [ {
    "ticket" : {
      "locator" : "QWF2A8C6",
      "status" : "new"
    }
  }, {
    "ticket" : {
      "locator" : "DNW18Y5T",
      "status" : "new"
    }
  }, {
    "ticket" : {
      "locator" : "V3W32JFB",
      "status" : "new"
    }
  } ]
}

In the ajax definition, 'tickets' has been added as the source to replace 'data' and the datatable is aware and shows 3 rows.

 "ajax": {
            "dataSrc": "tickets",

With the column defs:

columnDefs: [
                {
                    title: "Locator",
                    data: "ticket.locator",
                    targets: 0
                },

            ],

I've tried a number of 'data' definitions without success. They all result in a "DataTables warning: table id=dataTable - Requested unknown parameter '0' for row 0, column 0. For more information about this error, please see http://datatables.net/tn/4" error.

Can DataTables include data in this format? What would the correct syntax for the columnDef for data (ticket.locator does not work)?

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

light gallery feature disappears after using search, sort and next page in datatable

$
0
0

Hi guys, I've recently dabbled in implementing a datatable into my website. (this is the first website I've ever worked on, so it's a template I've bought and redesigned.)
So I have recently made a table with a lot of 'disciplines' from a game called Crowfall.
It can be seen here: https://vanguardcrowfall.com/disciplines

My problem is, if you try and click on the images in the table, the images on the first page will pop up and show up like in the light gallery as they should.

But if you use the sort function, search function or go to next page in the table, the pictures from clicking on the icons, won't act as if they were in the light gallery.

And I would like all the icons to work like they work on the first page of the table.

Hoping someone could help with this.

Select rows to show by keyword

$
0
0

Hello!

There is a Google Spreadsheet which I want to embed into website on WordPress.
As I understand it, DataTables has flexible filtering by various parameters, but unfortunately I can’t understand how it works.

In one column of my table I will indicate the tags by which I want to filter.
I want to display in the embedded table only those rows that have the required keyword.

So I need filtering not by user in the front-end, but to display only pre-selected rows by tag.


Add class to rows on table B by selecting row on table A

$
0
0

Hi all,

I have two tables on the same page with different data except for a single column that may have the same data in both of them (think products and categories and both share the cat ID column).

Example here: http://live.datatables.net/sabiluju/1/edit

The goal is when selecting a row from the top table to add the class hidden to the rows on the second table that have the same cat ID and when deselecting to remove it.

datatable single line(ajax)

$
0
0

I want to make a single line table into a datatable. Is it possible?

I am using ajax. My json is this.

{
name: "Tiger Nixon",
position: "System Architect",
salary": "$320,800",
}

I did it like below, a message saying 'No data available in table'
And type error.

data : data,
columns : [
{"data" : "name"},
{"data" : "position"},
{"data" : "salary"},
]

Please answer.Thanks

Leaving data alone

$
0
0

I'm sure this is out there somewhere I'm just not using the right search criteria. If we input something like January 21-23 into a text field (using latest DT & Editor) it converts that to a date. Is there a universal way to tell DT / Editor to treat the data as verbatim and not convert to a date (or an int ... etc.)?

DataTable error count(): Parameter must be an array or an object that implements Countable

$
0
0

I am using Laravel for this, all other things and functions work properly. Datatable call in other functions work properly but in this function it throws
count(): Parameter must be an array or an object that implements Countable

Code is as following

 $clicks=History::orderBy('id','DESC');
  return DataTables::of($clicks)->make(true);

Does anyone know why is it happening?

Export all regardless of pagination

$
0
0

I've searched and searched for this, but can't seem to find a straightforward answer -

I have a collection of export buttons that looks like this:

buttons: [{
  extend: 'collection',
  className: 'exportButton',
  text: 'Data Export',
  buttons: ['copy','excel','csv','pdf','print'],
  exportOptions: {
    modifer: {
      page: 'all',
      search: 'none'`    }
  }
}]

What I need is for each of those buttons to export the contents of whatever the table is displaying, regardless of pagination. Currently, if I run a search, and then export with any of those buttons (besides 'print'...oddly) the exported file or clipboard copy only contains the amount of rows as selected in the length dom box.

Is there a way that I can bypass this, and get an export with all matching records of any search?

EDIT: Updated code formatting to use Markdown

Viewing all 81908 articles
Browse latest View live


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