I'm using dynatable to power up my tables. It's how I'm using it:
function getData(obj) {
$.getJSON("AjaxEngine/AddPayment.aspx", { sender: "seller-factor", id: 1 })
.done(function (data) {
var dynatable = $('#factors-table').dynatable({
dataset: {
records: data.Factors
},
features: {
paginate: false,
search: false,
recordCount: true,
perPageSelect: false
}
})
.bind('dynatable:afterProcess', bindSelectRow);
}
getData()
will be fired on change()
event of a select
. When user select an Item for the first time it works fine, but when selected item changes it won't load new data. I asked in plugin's couple of days ago but got no answer.
I've tried multiple methods, like this one:
function getData(){
$.getJSON("AjaxEngine/AddPayment.aspx", { sender: "seller-factor", id: 1 },
function (data) {
var dynatable = $('#factors-table').data('dynatable');
dynatable.records.updateFromJson({records: data});
dynatable.records.init();
dynatable.process();
});
}
It says dynatable.records
is undefined while when I log dynatable
it's an object.
I think as a trick it would be possible to check if dynatable
is applied to the table and if it is, destroy it first then re-apply it, But I don't know how to do it.
JSFiddle: http://jsfiddle.net/maysamsh/pDVvx/16/
Well, after couple of hours I managed it with this code:
$.getJSON("AjaxEngine/AddPayment.aspx", {
sender: "seller-factor", id: obj.val() },
function (data) {
var dynatable = $('#factors-table').dynatable({
dataset: { records: data.Factors } },
{ features: { pushState: false }}).data("dynatable");
dynatable.settings.dataset.originalRecords = data.Factors;
dynatable.process();
});