Data not getting displayed in the table
Data not getting displayed in the table

I am using datatables. I have collection with models as rowViews in it. How should i pass the collection to datatables, so that the data gets rendered in the table
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
Please provide a link to your page, or to a test case demonstrating the issue.
https://datatables.net/forums/discussion/12899/post-test-cases-when-asking-for-help-please-read#latest
@tangerine and @allan can u please help me here, not understanding how to use ajax .
I have the collection in my hand and not able to pass it to the datatable. I am appending the rowViews
datatableDefault["serverSide"] = true;
datatableDefault["ajax"] = {
"url": baseurl
"data": function ( d ) {
delete d.columns;
return d;
renderList: function(){
this.clearAllRowViews();
this.list.api().clear();
if(this.collection.length > 0){
this.collection.forEach(this.appendRowWithoutDraw, this);
}
appendRowWithoutDraw: function(model, index){
this.appendRow(model, {drawTable: false, index: index});
},
appendRow: function(model, options){
var rowView = this.createRow(model, options.index);
this.rowViews.push(rowView);
if(!!options && options.drawTable === false){
this.list.api().row.add(rowView.render().el);
} else {
this.list.api().row.add(rowView.render().el).draw();
}
},
Not understanding how to implement server side, since i already have all the data in the collection. i want to render using serverside
@allan or anyone can u please look into this and help me understand how to do it
First thing I would suggest is to remove the
serverSide
option (unless you are handling 50’000 or more rows of data) as it will just make things more complicated.Next, have your server-side script return the data from the database in JSON. If you aren’t sure how to do that, have a look on StackOverflow and similar.
Finally, once you have the JSON data, DataTables will be able to consume that. If you aren’t sure how to do that, post a sample of the JSON the server is returning here and we’ll help you configure your DataTable.
Allan
@allan thanks for your reply, we will use json structure