I am trying out Dynatables and, so far, I am able to display my data correctly and update its contents when a certain event happens. So far, this is what I have: http://jsfiddle.net/pDVvx/28/
$(document).ready( function() {
var allSales = [{
locationId: 1001,
location: "Store A",
item: "Soap",
quantity: 2,
amount: 99.50
},{
locationId: 1002,
location: "Store B",
item: "Tissue",
quantity: 1,
amount: 49.75
}];
var allSales2 = [{
locationId: 2001,
location: "Store C",
item: "Bag",
quantity: 1,
amount: 10000.00
},{
locationId: 2002,
location: "Store D",
item: "Shoe",
quantity: 2,
amount: 5999.50
}];
var locationDetails = [{
locationId: 1001,
location: "Store A",
address: "some address here",
manager: "Pepito Manaloto"
},{
....
}];
var updateDynaTable = function(argument){
console.log("argument for updateDynaTable");
console.log(argument);
dynatable.settings.dataset.originalRecords = argument;
dynatable.process();
}
var dynatable = $('#my-final-table').dynatable({
dataset: {
records: allSales
}
}).data('dynatable');
$("#button1").click(function(){
updateDynaTable(allSales);
})
$("#button2").click(function(){
updateDynaTable(allSales2);
})
});
Furthermore, I want to make each location (Store A, Store B, etc.) a clickable link with the respective locationID associated with it. I need this so that whenever I click a store link, the corresponding store details (as shown in locationDetails table) will be prompted.
For example, if sales1 button is clicked and Store A is also clicked, a prompt (could be an alert) will show the store's address and manager (from locationDetails table).
If anyone can suggest any solution, that would be very helpful. Thank you!