Hi,
I need to add columns in a datagrid;
I know that the only way to do this is recreating the datagrid.
I've also find this
Here is the extended method that can re-create datagrid without sending request.
$.extend($.fn.datagrid.methods,{
recreate:function(jq){
return jq.each(function(){
var dg = $(this);
var opts = dg.datagrid('options');
var url = opts.url;
var pageNumber = opts.pageNumber;
opts.url = null;
var data = dg.datagrid('getData');
dg.datagrid();
dg.datagrid('loadData',data);
setTimeout(function(){
opts.url = url;
opts.pageNumber = pageNumber;
dg.datagrid('getPager').pagination('refresh',{pageNumber:pageNumber});
},0);
});
}
});
Calling $('#dg').datagrid('recreate') is same as $('#dg').datagrid() but does not re-request data from server.
And it seems to be the solution to my problem, but:
Because of my datagrid has a lot of properties setup (celledit mode, sort, event callbacks,whether striped or not ....), I'd like to know if with that recreate trik all the properties arre maintained, and if not, how to achieve this.
Thanks,
Ric