getting the first row
getting the first row
When my page comes up and the datatable is drawn, I want to get the first row of data. I tried fnGetData(0) -- it seems to be returning the first item of raw table data before sorted by datatables
Using firebug, I was able to get what I want like this:
[code]console.log(oTable.dataTableSettings[0].aoData[ oTable.dataTableSettings[0].aiDisplay[0] ]._aData[0]);[/code]
BUT...I'm not sure I should be accessing things like that. Is there a clean way to do this through the api??
Using firebug, I was able to get what I want like this:
[code]console.log(oTable.dataTableSettings[0].aoData[ oTable.dataTableSettings[0].aiDisplay[0] ]._aData[0]);[/code]
BUT...I'm not sure I should be accessing things like that. Is there a clean way to do this through the api??
This discussion has been closed.
Replies
[code]
$('tr', oTable.fnSettings().nTBody)[0]
[/code]
I've never needed to do something like that, so I can't tell you if that's going to work properly or not.
oTable.fnGetData( $('#example_table tbody tr:eq(0)')[0] );
[/code]
is how I would recommend doing it. Basically you want a reference to the first TR in the TBODY, which you can get using getElementsByTagName or jQuery as I've done above - and then pass that in to fnGetData.
Allan
I have to get only 1st column value of N number of rows in data table, can you help me in this.
presently i am using oTable.fnGetNodes() here, I am getting all the column values in a row that will be huge data because of that browser is alerting stop scripting.
Allan
But my 1st column in table is checkbox here, I am not able ready the value of checkbox checked, var input=jQuery('input:checkbox:checked', oTable.fnGetNodes()); I am getting input has 0 kindly help me.
this is returning me some value but
var input = jQuery('input:checkbox:checked', oTable.fnGetColumnData()); this is not returning any value to me.
It wouldn't since that is working with strings not nodes.
What you can do is (note that this needs DataTables 1.9):
[code]
$('#example').dataTable().$('td:nth-child(1) input:checked')
[/code]
that should do it :-)
Allan
IE 8 browser is not supporting for rendering of 1500 data in datatable
if i used oTable.fnGetNodes().
[code]
nodes = $('#example').dataTable().fnGetNodes();
$('td:nth-child(1) input:checked', nodes);
[/code]
but it is worth upgrading to 1.9 (full release of 1.9.0 soon).
> IE 8 browser is not supporting for rendering of 1500 data in datatable
1000-2000 is about the limit for IE8 with client-side processing because it is so slow. You might want to consider Ajax loading data with deferred rendering or server-side processing.
Allan
A.I want to delete complete row of tbody of my datatable without deleting header and foot, I am trying lot but not able find how to do this,kindly help me over this issue.
B.I want to delete specfic row of DataTable of tbody can you please provide the query for this.
[code]http://datatables.net/forums/discussion/7277/getting-the-first-row
$('table#fp').dataTable( {
"sDom" : 'lrtfp',
"bPaginate" : false,
"bProcessing": false,
"bstatesace" : true,
"sAjaxSource": './data.php?request=fp',
"fnDrawCallback": deleteRow
}
function deleteRow(oSettings) {
//replace the 1 with the row # you wish to delete note that this fuction uses CSS
//style counting starting from 1
$(oSettings.nTable).children("tr:nth-child(1)").remove();
}
[/code]
*note code not tested
Use fnDeleteRow (unless you are using server-side processing, in which delete the row at the server and then redraw the table with fnDraw ).
> B.I want to delete specfic row of DataTable of tbody can you please provide the query for this.
Again use fnDeleteRow with client-side processing tables. Just give the function the TR node you want to delete, as noted in the documentation.
Allan
How to get the length of column in datatable dynamically in javascript method.
But I have one more doubt about grouping,
assume i have 20 rows in that 1st 5 rows of belongs to Firefox, next 5rows belongs to IE,
next 5 rows belong chorme and last 5rows belong to safari. In this condition i dont wont to display all twenty rows, I like to dispaly only Group name of browser(i.e one 4 rows of browser) can you help me in that please.
Thanks,
Abhi.