Using javascript datasource and created row
Using javascript datasource and created row
MadBoyEvo
Posts: 119Questions: 38Answers: 0
I use following code to highlight field based on data. This works as long as datasource is HTML.
"createdRow": function (row, data, dataIndex, column) {
if (data[5] == 'False') {
$(column[5]).css({
"background-color": "#ff0000"
});
}
}
But if I define datasource inside JS (for performance reasons) things are not working. Is there a workaround?
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
What things exactly? What happens.. Do you get errors in the browser's console?
Kevin
No, just nothing happens. It seems when JavaScript source is used:
So the above works. So it would seem depending if it's HTML source or JavaScript source I need to apply different approach.
Ok, I was wrong. If I just change data[5] to data.ColumnName it works - so it seems it's just matter of how I handle data comparison.
Edit:
Or I thought it works, but now that I test it - not so much
But it's enough for me to have different calls - rowcallback for JavaScript source and createdRow for HTML. Thank you.
The difference is whether you are using array data or object data. If you define
columns.data
you are using object data and need to access using object notation such asdata.HandleCount
instead ofdata[5]
.createdRow
will work with either DOM sourced data or Javascript sourced data.Kevin