Repeat reloading server processed source data

Repeat reloading server processed source data

UltradivUltradiv Posts: 1Questions: 0Answers: 0
edited March 2014 in DataTables 1.8
I created a datatable driven by classic asp vbscript along with a stored procedure in SQL Server

I needed to be able to open a modal window with row #id related stuff AND have an icon for fnOpen the details when clicking on that rows icon.

so I used two click event handlers like this:

[code]
$("#dt_basic tbody").delegate("td.isAction", "click", function(event) {
var nTr = event.target.parentNode;
while (nTr){
if (nTr.nodeName == "TR") break;
nTr = nTr.parentNode;
}
var position = oTable.fnGetPosition(nTr);
var contactId = oTable.fnGetData(position)[0];
var hasAction = oTable.fnGetData(position)[1];
if(hasAction==1){
if ( oTable.fnIsOpen(nTr) ) {
oTable.fnClose( nTr );
} else {
$.post('/ajax/sellers_action_list.asp',{sellerId:contactId},function(data){
oTable.fnOpen( nTr, data, "info_row" );
});
}
}
});

$("#dt_basic tbody").delegate("td.notAction", "click", function(event) {
var nTr = event.target.parentNode;
while ( nTr ){
if ( nTr.nodeName == "TR" ) break;
nTr = nTr.parentNode;
}
var position = oTable.fnGetPosition(nTr);
var contactId = oTable.fnGetData(position)[0];
var fName = oTable.fnGetData(position)[2]+' '+oTable.fnGetData(position)[3]+' '+oTable.fnGetData(position)[4];
fillModal(contactId,fName);
});
[/code]

They now work perfectly BUT it took me two days!!! to debug the page because every time the table was loaded from the server sourced data it loaded 4 or 5 times simultaneously so when the new detail row was opened it immediately closed again as the next data set over wrote it.

I write this just to inform anybody with a similar issue because I had on the page a piece of code I got from this forum to reset the row widths on window resize thus:
[code]
$(window).bind('resize', function () {
oTable.fnAdjustColumnSizing();
});
[/code]

Not exactly related I would have thought, but it obviously calls a refresh of the data even without resizing the window somehow.
Anyway once removed it all works beautifully.

Datatables is a wonderful work, thanks Allan

Replies

  • allanallan Posts: 61,972Questions: 1Answers: 10,160 Site admin
    I think fnAdjustColumnSizing is doing a redraw there, which is why you were seeing the issue.

    DataTables 1.10 has this functionality built in, and doesn't trigger a redraw: https://github.com/DataTables/DataTables/blob/master/media/js/jquery.dataTables.js#L3986 :-)

    Allan
  • allanallan Posts: 61,972Questions: 1Answers: 10,160 Site admin
    p.s. Thanks for the kind words!
This discussion has been closed.