Need help with saving row data when clicked on & saving the state from one tab to another tab

Need help with saving row data when clicked on & saving the state from one tab to another tab

svu004svu004 Posts: 3Questions: 0Answers: 0
edited March 2014 in DataTables 1.9
Hi,

I am very new to datatables. I have a JSON data that is passed to in response to AJAX call, and then, invoke the datatables on the json data as follows, and activate one tab of the page to contain the output of this datatable. I have couple of problems:

1. When the user selects a particular row, I need to keep track of the row data in a datastructure. Is there a better way to do it than what I doing below? How can we have the oTable.$('tr').click(function() to be defined out of the Ajax post response?

2. When the page tab which contains the output of the below datatable is switched with another tab, then, the oTable.$('tr').click(function() doesn't work anymore? Is there a solution or another option to do it?

3. If we need to have columns within columns, how can we do it with Datatables?

Can some one provide me some pointers for the above questions, which would be really helpful to me...

[code]
success: function(response) {

oTable = $("#example_table_id").dataTable({
"bProcessing": true,
"bAutoWidth": false,
"iDisplayLength": 10,
"aoColumns": response.aoColumns,
"aaData": response.aaData
});

//Register event handling for when the row is clicked on:

var oTableData=new Array();
oTable.$('tr').click(function() {
var oData = oTable
.fnGetData(this);
console.log(oData);
var index = oTableData
.indexOf(oData);

if (index != -1) {
oTableData.splice(index, 1);
} else {
oTableData.push(oData);
}

console.log(oTableData);

});

}

[/code]

Replies

  • svu004svu004 Posts: 3Questions: 0Answers: 0
    Can someone help with providing any pointers for these questions?
This discussion has been closed.