How to sort nested JSON object and display using handlebars?
How to sort nested JSON object and display using handlebars?
I have an AJAX request whose response is a nested object. Post some condition check, I display the data in a table using handlebars. So right now my request looks like this:
$.ajax({
async: false,
url: serverAPI + '/<some_path>/' + ID,
success: function(data) {
$.each(data.details, function(index, element) {
if (element.detailStatus != 'Removed') {
element._id = dummyId
element._field = field
var html = templateTemp(element)
placeholderTemp.append(html)
}
});
},
error: function(err) {
console.log(err);
}
});
Now new requirement is to make the columns sortable. How to use DataTables in this scenario? How to do my if condition check within datatable? Where does handlebars append go? How to handle ajax error? Do I need to rewrite this ajax request within Datatable plugin or there is a work around? Sorry, first time with datatables, hence such questions!!
Thanks in advance!