Callback before setting data from ajax
Callback before setting data from ajax

I have a very strange problem in my datatable. For a column, there is the wrong data loaded.
The data from the ajax call is okay, I checked the json.
So for one column, datatable takes the data from my backbone model class. Every value of this column is from the model variable. When I change the value in my model class, the value of the datatable column changes also.
I tried to rename the variable in the model, but datatable still takes the value from the model.
For debugging, I want to know if it is possible to have a callback before the data is set.
This question has an accepted answers - jump to answer
Answers
Hi @irxn84 ,
DataTables will just use the data in the DOM or the data you pass it - it sounds like your models are doing something clever. We're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.
Cheers,
Colin
My datatable is a bit complicated, the columns are dynamic for every view.
My ajax configuration:
The json I get:
Every data is displayd okay, except of the column environment.
Columns are defined as an array with render information and data attribute.
The data attribute is like in json id, error, type, environment.
Everything is okay, but just the environment is not loaded from json.
I can debug this myself. But I need a hint where datatables is setting the data from the json. So than I can check, where the wrong environment is coming from
Your data example seems to render just fine here:
http://live.datatables.net/jukokoge/1/edit
In order to troubleshoot I would start with looking at the response in the Developer Tools. You could use the
ajax.dataSrc
or thexhr
event to see the JSON that Datatables is using. You can usecolumns.render
for the environment column to console.log thedata
parameter.Otherwise maybe you can update or post an example replicating the issue.
Kevin
This example used in my code does not work. I still get another value for environment.
When I rename the column for example to environment1, everything works fine.
So somewhere an environment variable is set in my code in the background. But I just did not find out where. In the render method there is already the wrong data. I now did not use ajax, but the data directly like in the example
As Kevin said, we're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.
Cheers,
Colin
Okay, I renamed the column in my application. I think this is the easier way to handle this. When I ever figure out, what the real problem was, I write it here in the thread.