Export current state of datatable
Export current state of datatable
I've looked over the plugins and documentation (and read alot of forum posts) and haven't seen anything on this yet. What I'd like to do is export the current state of the grid (filtered, sorted, searched - whatever ends up being available, hidden columns included) into JSON or something that could be sent and parsed server side. The TableTools plugin exports, so it should contain most of the logic needed - but is that the best starting point? Is there a function I'm overlooking on the base DataTables?
BTW - incredibly nice work on this. By far the best datagrid plugin I've seen to date.
BTW - incredibly nice work on this. By far the best datagrid plugin I've seen to date.
This discussion has been closed.
Replies
Thanks for the kind words about DataTables! There isn't a built-in method or plug-in currently available which will do exactly what you are looking for. As you say, TableTools could be altered to do it, but that seems like overkill to me. You basically want fnGetData() which will take account of sorting etc, so try something like this:
[code]
/*
* Function: fnGetDisplayData
* Purpose: Return an array with the data arrays used for displaying the table
* Returns: array node: data array elements
* Inputs: object:oSettings - automatically added by DataTables
*/
$.fn.dataTableExt.oApi.fnGetDisplayNodes = function ( oSettings )
{
var aaData = [];
for ( var j=0, jLen=oSettings.aiDisplay.length ; j