FixedColumns - oDT is undefined unless processed on server

FixedColumns - oDT is undefined unless processed on server

parliament718parliament718 Posts: 2Questions: 0Answers: 0
edited October 2013 in General
I'm experience a strange bug where I'm unable to call fnCallback successfully unless I call it inside an ajax success callback. However, sometimes the table already has the data it needs in the cache (from a previous request) and I want to avoid an unneccesary request (thus the "preventDataRequest" flag). However, if I take the control flow, I get "oDT is undefined" from FixedColumns down the line. The models passed into each fnCallback are identical so why is this happening?

[code] self.dataTable = $(self.tableSelector).dataTable({
bServerSide: true,
fnServerData: function (sSource, aoData, fnCallback) {
//Convert [{ "name" : "sEcho", "value" : 1},{ "name" : "iColumns", "value" : 12}, ... ]
//Into { sEcho: 1, iColumns: 12, ... }
var dataTableQuery = _.object(_.map(aoData, function (x) { return [x.name, x.value]; }));

if (self.preventDataRequests) {

self.resultSetModel.DataTableModel.sEcho = dataTableQuery.sEcho;

fnCallback(self.resultSetModel.DataTableModel); //This causes the error

} else {
var resultSetQuery= {
DataTableQuery: dataTableQuery
};


$.ajax({
contentType: 'application/json',
dataType: 'json',
type: 'POST',
url: "/Controller/Action",
data: JSON.stringify(resultSetQuery),
success: function(resultSetModel) {

fnCallback(resultSetModel.DataTableModel); //This works fine

}
});
}
},

fnInitComplete: function(settings, json) {

//If ajax request was not made (when self.preventDataRequest == true), then self.dataTable equalls undefined here and results in "oDT is undefined error"

self.dataTableFixedColumns = new FixedColumns(self.dataTable, {
...
});

},
}) [/code]

Replies

  • parliament718parliament718 Posts: 2Questions: 0Answers: 0
    edited October 2013
    I still haven't resolved this issue would appreciate some help. As I noted the models passed to fnCallback are identical in both control flows so why does one call throw an error (if I bypass the ajax request) and another doesn't (if I send the request)?
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    We'd probably need a link to a test case I think, but what is the value of `self.resultSetModel.DataTableModel` on the first draw? Also what is the value of `self.dataTable` in the error condition?

    Allan
This discussion has been closed.