I am attempting to use "simple data grid" to display multiple unique (tables) grids on a single page. In the code below I am unclear how to pass unique data to the function below instead of var data = ExampleData.fruits. Every attempt I have made so far to add a second table with unique data results in all data being broken. (I do need all the existing functionality sorting highlighting on click, pagination etc).
I have created this jsfiddle that is working with a single grid and the sample data. I have commented out a bit of code for a second set of data that I was trying to work with.
ExampleData = {};
ExampleData.handleMockjaxResponse = function(settings) {
var uri = new Uri(settings.url);
var page = uri.getQueryParamValue('page') || 1;
var order_by = uri.getQueryParamValue('order_by');
var sortorder = uri.getQueryParamValue('sortorder');
var rows_per_page = 6;
var start_index = (page - 1) * rows_per_page;
var total_pages = 1;
var data = ExampleData.fruits; //How can I pass this data so that multiple tables can exist with different data
if (data.length != 0) {
total_pages = parseInt((data.length - 1) / rows_per_page) + 1;
}
if (order_by) {
data.sort(function(left, right) {
var a = left[order_by];
var b = right[order_by];
if (sortorder == 'desc') {
var c = b;
b = a;
a = c;
}
if (a < b) {
return -1;
}
else if (a > b) {
return 1;
}
else {
return 0;
}
});
}