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

Log table for errors

$
0
0

I currently use the server side events to log changes, as described here:

function logChange ( $db, $action, $id, $values ) {
    $db->insert( 'staff-log', array(
        'user'   => $_SESSION['username'],
        'action' => $action,
        'values' => json_encode( $values ),
        'row'    => $id,
        'when'   => date('c')
    ) );
}
 
Editor::inst( $db, 'staff' )
    ->fields(
        Field::inst( 'first_name' ),
        Field::inst( 'last_name' ),
        Field::inst( 'position' ),
        Field::inst( 'email' ),
        Field::inst( 'office' )
    )
    ->on( 'postCreate', function ( $editor, $id, $values, $row ) {
        logChange( $editor->db(), 'create', $id, $values );
    } )
    ->on( 'postEdit', function ( $editor, $id, $values, $row ) {
        logChange( $editor->db(), 'edit', $id, $values );
    } )
    ->on( 'postRemove', function ( $editor, $id, $values ) {
        logChange( $editor->db(), 'delete', $id, $values );
    } )
    ->process( $_POST )
    ->json();

However, it would be really useful to also log errors associated with datatables events. For example, the information which appears if you have ->debug( true ) enabled or JSON response errors.

Has anyone else tried/achieved this? I am just at the thinking it through stage so was wondering if anyone had any experience?

Thanks


server side processing stuck at "processing" after ordering

$
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

Datatables break with multiple datatables within tabs

$
0
0

I have an issue were I get the following error:

TypeError: this.api.cell(...).index(...) is undefined; can't access its "column" property

What I wanted to ultimately accomplish is to have a datatable per tab on a page and have the databales be responsive to mobile viewports. But it's only responsive for the first tab and breaks on the second tab.

As mention above the code breaks on the next tab and specifically on the second row of the datatable within the next tab.

I have over simplified my code here, without removing the main components.

I'm building this page based on a template and the javascript code use to manipulate the datatables comes from that template. Like I said it works for the first tab and crashes on the second row of the datatable in the next tab.

I'm no expert in javascript however I'm currently trying to debug the issue myself. But if I can have this issue resolve by the experts here then I would greatly appreciate that as I don't have much time and wasn't expecting to have this error. I have search the internet and this forum for any situation similar to mine but didn't find anything the closest thing I have found is an issue with the columns needing resizing when a tab is shown.

My actual page has six tabs and I noticed from some testing that its always the next tab. Currently in the pastebin code I have referrenced above their is a datatable code for each tab its always the second javascript code that crashes hence I said the next tab. So it issue goes as follow:

javascript code for Tab1 and Tab2 = Tab1 working Tab2 row2 crashes
javascript code for Tab2 and Tab3 = Tab2 working Tab3 row2 crashes
javascript code for Tab3 and Tab4 = Tab3 working Tab4 row2 crashes
javascript code for Tab4 and Tab5 = Tab4 working Tab5 row2 crashes
and ...so on

Just mention this incase it helps with debugging.

If anymore information is need please let me know.

Thanks,
Jerg

DELETE from table with database name prefix in Editor PHP

$
0
0

Hello, I think there is a little inconsistency using database name prefix in Editor (1.6.3)
Suppose I have something like
$editor = Editor::inst( $db, 'db.table' )
and all fields referencing db.table.field
Then I'm not able to delete records from this table.
In Editor.php file there is a _remove_table function with condition:
$this->_part( $field->dbField(), 'table' ) === $table && ...
The table on the left side doesn't have a prefix while on the right side there is a db.table variable.
I think that's why the DELETE query is never generated.
There should be probably something like:
$this->_part( $field->dbField(), 'db' ).'.'.$this->_part( $field->dbField(), 'table' ) === $table && ... instead.

How to print table footer on last page only?

$
0
0

I'm using the Buttons extension, Print option and I only want the table footer <tfoot> to print on the last page. I tried to just put it in a row <tr><td> at the end of the table, but that doesn't work when I use a custom sort. Any ideas on this?

Error with Sqlite

$
0
0

I'm getting the following error when I try to use DataTables dll in .NET Core project

The specified invariant name 'Microsoft.Data.Sqlite' wasn't found in the list of registered .NET Data Providers.

Any idea how I can fix it?

Here is code that is creating the error

using (var db = new Database(dbType, dbConnection))
                {

Change colour of row based on column value

$
0
0

Hello,one of the columns in my table contains a due date, i would like to change the colour of the row to red if the due date has already been reached (due date is in the past), if it has not been reached then the colour should change to green.
I am using php to load the data from the tables if that helps.
Thanks

Searchs without accent (and special character)

$
0
0

Hi,
I would like to search in French without accent, by example I could find "été" with searching "ete" or "été" or "éte"
It is possible with datatables ?

Thank you


How to avoid RangeError maximum call stack size exceeded?

$
0
0

Enclosing certain statements that load or initialize the DataTable. I have for example a setTimeOut that refreshes it every 30 seconds with ajax.reload.

But it is a component that has to launch this error and it would be good to publish how to avoid these errors and get the best performance. Because it uses many resources to achieve desired functionalities

Insert or Update record to a joined file if it does not exsist.

$
0
0

How could I insert or add a record to a joined file in DataTable Editor.

As an example, I have 2 files Payroll and Stock Contribution file.

The Payroll file would be used as the main driver file, it contains all employees.

The Stock Contribution file contains records only if an employee has made a dollar amount contribution. (joined file)

The front-end DataTable would contain data from both files.

If the employee does not have a record in Stock Contribution file the column for dollar amount would be 0.00 (this column would be available for inline editing).
If dollar amount is entered, I would need to insert the record into the Stock Contribution file.

If the employee does have a record in Stock Contribution file and the column for dollar amount was changed, I would need to update the dollar amount field in the Stock Contribution file.

I would use an Ajax call from the front-end script to call a server-side script (SSP) which would perform this function.

Are there any examples of this architecture I can refer to?

Parsing "\n" new lines in HTML from JSON string.

$
0
0

So, a little background. I have a datatable set up, it's really rough around the edges, just to display a whole bunch of data from a JSON database. This is how I have it set out

$(document).ready(function() {
    $('#data').DataTable( {
        "ajax": {
            "dataType": 'json',
            "url": "domains.json",
            "dataSrc": "cards"
        },
        "order": [ 3, "desc" ],
        "columns": [
            { "data": "name" },
            { "data": "desc"},
            { "data": "shortUrl",
              "render": function(data, type, row, meta)
              {
                if(type === 'display')
                {
                    data = '<a class="trello-link" target="_blank" href="' + data + '">' + data + '</a> \n Open in Incognito';
                }

                return data;}
            },
            {  "data": "dateLastActivity"}
        ]
    } );
} ); 

And this is pulling information from the JSON database source. The data in the second column "desc" is a string that displays as such in the JSON:

"Some information here\nMore information here\nNext information here"

The "\n" when parsed through into the datatable doesn't form a new line, is there any way this can be performed without major changes to the database structure itself?

Kind Regards,
Ben

Move search boxes for each column just below the table header

How to export actual data after javascript update?

$
0
0

Hello!
I use DataTable to export spreadsheet to excel and pdf.
My table is updated by Ajax. But without using DataTable. After filtering or paging, non-updated data is exported. Those that were in the table when the page was loaded and the DataTable was initialized.
table.rows (). invalidate ('dom'). draw (); also brings the table to its original form.
table.destroy (); and re-initialization also inserts the original data. I ask for help, I will be very grateful.

My code is:

 <script>
    $(document).ready(function() {
        
         var table;
         init_table();
        
    $('#update_d').on("click", function(){
        
     update_data();
        
    })
        
} );
 
     function init_table(){
         
       setTimeout(function(){ 
       table = $('.datagrid_wrapper > table').DataTable( {
        dom: 'Bfrtip',
        paging: false,
        searching: false,
        bRetrieve: true,
        info: false,
        buttons: [
             'csv', 'excel', 'pdf', 'print'
        ]
    });
   },1000);  
         
     }
     
     function update_data(){
         
     table.rows().invalidate('dom').draw();
         
     }
     
</script>

Prevent multiple ajax requests in server side pagination

$
0
0

In server side pagination, multiple ajax calls are made rather than one at a time. I want to fetch 10 records first and so on but there are many ajax requests are made.
I have tried too many different ways but cant solve the problem.
How to prevent ajax to make multiple requests in server side processing?
Data table is initialized under document.ready()

Prevent multiple ajax requests in server side pagination

$
0
0

In server side pagination, multiple ajax calls are made rather than one at a time. I want to fetch 10 records first and so on but there are many ajax requests are made.
I have tried too many different ways but cant solve the problem.
How to prevent ajax to make multiple requests in server side processing?
Data table is initialized under document.ready()


Is it possible to insert into two separate databases?

$
0
0

Hello,
So I am working with an application in which a user enters a cohort name, along with a group name. Each cohort can hold multiple groups, which is linked in the database by a foreign key in the group table. I wan't to insert both the cohort name and group name in their respective tables. At the moment I only can get the cohort to insert and not the group. Is it possible to do this without making a separate file for it?

Copy/paste to general search field

$
0
0

I am experiencing a seemingly random issue where spaces will be removed from clipboard text when pasting the text to the general search field in the upper right corner of the data table. For example, the following text,

a • b • c

may get pasted as the following slightly modified text:

a •b • c

Notice that the space between the bullet and the 'b' was removed. I wonder if anyone else has experienced this issue.

Thanks!

Highlight an entry in row if contains pattern

$
0
0

Hi,
New to DataTables so please pardon if a re-post.
Is it possible to highlight an entry (either bold or different color) in a row if it contains a pattern? Eg.,
Make the 3rd entry bold if it contains a 'G'.
T/G G/G **A/G** NA A/A NA

To take it further, is it possible to make only 'G' appear in bold (and not 'A')?
T/G G/G A/**G** NA A/A NA
Thanks so much!

Datatables sourced from IndexedDB.

$
0
0

Hi,
I'm trying to find a solution to source Datatables from IndexedDB with lazy loading. Something similar to ajax server-side processing but to be cliend-side processing with indexedDB.
So far I ended up firstly reading from indexedDB to JS object and then use it as data source for Datatables. Further data modifications are also successfully done by writing into the respective object and indexedDB. That works almost perfectly. With 8000 lines of data the data loads within 3 seconds (0.5 from indexedDB to JS object, and 2.5seconds rendering the datatables).
At some moment I may need to go beyond 8000 lines, and I would like to have the possibility to lazy-load data straight from indexedDB. Has anyone succeeded?

I've seen 1 example on forum with indexedDB, but that one uses same approach. There is also one example with localStorage, which also is not doing any lazyloading.

Thank you

table pops outside of the popup

$
0
0

i'm using sorting technique for sorting a table which is present inside of a popup..in chrome and IE sorting and searching working fine but in IE the table comes out of the popup width wise.how to solve this?

Viewing all 79584 articles
Browse latest View live




Latest Images