API-Method seem to be very slow
API-Method seem to be very slow
Oensel
Posts: 19Questions: 4Answers: 1
I just want to get all the data of a row, by mouseenter on special cells, for saving it in an array for easy access.
But this takes about 2,5 seconds, what is too much for opening popups with detailed informations.
Am I doing something wrong ?
$('#'+tabellenname+' tbody .showTooltip').on('mouseenter', function(event)
{
// Daten der Zelle, Zeile und Spalte auslesen
var columnIndex = tableApi.cell( this ).index().column;
var rowIndex = tableApi.cell( this ).index().row;
var spalte = $(tableApi.column( columnIndex ).header()).text();
var data = new Array();
for(var index = 0; index < spaltenArray[tabellenname].length; index++)
{
var title = spaltenArray[tabellenname][index];
if(tableApi.row(rowIndex).data() !== undefined)
{
data[title] = tableApi.row(rowIndex).data()[index];
}
}
});
This discussion has been closed.
Replies
Your code looks a little over complicated just to get the data for the row I think - why not just use
row().data()
directly?Allan
Hi Allan,
thanks for your answer, but I need key/value pairs of the data, because I access the data by it's headers title in the following code.
Getting the data by your code is very fast, so I will use this ;-)
But now I need to get the title of each column as fast as possible, including hidden columns title.
Then I can match it by the index.
OK, I got it myself:
Yes that sounds like a good way of doing it. You could also use
each()
rather than$.each
to save a line or two if you wanted:Having said that, I think a better solution would probably be just to load objects into the table in the first place, rather than using arrays.
Allan