On an implementation of the DataGrid loading column name dynamic Add, due to project requirements, need to set a timer on this page, 3 seconds to refresh, with the DataGrid reload method Refresh will have a splash screen effect, online search on this page to add CSS style method although the Flash screen has a certain improvement, But the effect is still poor, you can see the traces of the refresh. So think of Ajax asynchronous refresh without splash screen effect, first set up a timer
SetInterval ("Freshgrid ()", 3000);
The next implementation of the Refresh Method Greshgrid ();
function freshgrid () {
//$("#grid").datagrid("reload ");
var grid = $ ('# grid');
var options = grid.datagrid ('getPager'). data ("pagination"). options;
var page = options.pageNumber; // Get the current page number
var rows = options.pageSize; // Get the set number of rows displayed per page, these two parameters are needed for pagination query
$ .ajax ({
type: 'POST',
url: 'queryResult.action',
data: {'queryId': $ {param.queryId}, 'rows': rows, 'page': page},
success: function (data) {
$ ('# grid'). datagrid ('loadData', eval ('(' + data + ')'));
}
});
}
The background is returned in the standard JSON format (the last mentioned format).
Write here if the column name is added dynamically at the beginning of loading, there will be no error, but the column name that was added dynamically at the beginning of the project is empty, and then the source of the refreshed Easyui does not refresh the column name, so while the JSON has the corresponding data, it will not be displayed. At this point you need to add a column name to the source of the LoadData. easyUI1.3.2
Find LoadData first, in line 8173.
});
},loaddata:function (jq,data) {
return Jq.each (function () {
_4e5 (this,data);
_562 (this);
});
In _4e5 (this,data), add the resolution of the column name. This method is implemented in 7245 rows
function _4e5 (_4e6,data) {
var _4e7=$.data (_4e6, "DataGrid");
var opts=_4e7.options;
var dc=_4e7.dc;
Data=opts.loadfilter.call (_4e6,data);
Data.total=parseint (data.total);
_4e7.data=data;
if (data.footer) {
_4e7.footer=data.footer;
}
The code added in it is similar to the one added in the previous section
function _4e5 (_4e6,data) {
var _4e7=$.data (_4e6, "DataGrid");
var opts=_4e7.options;
if (data!=null && data.cols!=null) {
var cols = opts.columns[0];
var colcount=cols.length;
if (colcount==0) {
for (var i = 0; i < data.cols.length; i++) {
var col = {
Field:data.cols[i].field,
ti Tle:data.cols[i].title,
width:data.cols[i].width
};
Cols.push (col);
}
UI Add Column
if (colcount==0 && opts.columns) {
_494 (_4e6);}}
}
var dc=_4e7.dc;
Data=opts.loadfilter.call (_4e6,data);
Data.total=parseint (data.total);
_4e7.data=data;
if (data.footer) {
_4e7.footer=data.footer;
}
This enables Ajax to dynamically add a real-time refresh of column names asynchronously.