seno
30 Nov 2006, 7:29 AM
sorry for my pool english :(
i need chang grid column and data models dynamically
code below, it works.
but first execute time is 1636ms,
second is 1845ms,
third is 2103ms,
....
10 is 4322ms
any hints?
var getQuestionScoreCallback = function(resp){
eval(resp.responseText);
stopwatch.init();
stopwatch.start();
scoreGrid.container.update('');
scoreGrid.colModel.purgeListeners();
scoreGrid.colModel.config = json.headers;
var schema = {
tagName: 'item',
id: 'use_index',
fields: json.items
};
var dataModel = new YAHOO.ext.grid.XMLDataModel(schema);
scoreGrid.dataModel = dataModel;
//remove column resize splitbar div
for(var i = 0; i < scoreGrid.getView().columnSplits.length; i++) {
getEl(scoreGrid.getView().columnSplits[i].id).remove();
}
scoreGrid.getView().columnSplits = [];
scoreGrid.getView().indexMap = scoreGrid.getView().buildIndexMap();
scoreGrid.getView().render();
scoreGrid.getColumnModel().totalWidth = undefined;
var xml = loadXML(json.xml);
scoreGrid.getDataModel().loadData(xml);
stopwatch.stop();
alert("time consumed : " + stopwatch.getTime());
hideLoading();
}
i need chang grid column and data models dynamically
code below, it works.
but first execute time is 1636ms,
second is 1845ms,
third is 2103ms,
....
10 is 4322ms
any hints?
var getQuestionScoreCallback = function(resp){
eval(resp.responseText);
stopwatch.init();
stopwatch.start();
scoreGrid.container.update('');
scoreGrid.colModel.purgeListeners();
scoreGrid.colModel.config = json.headers;
var schema = {
tagName: 'item',
id: 'use_index',
fields: json.items
};
var dataModel = new YAHOO.ext.grid.XMLDataModel(schema);
scoreGrid.dataModel = dataModel;
//remove column resize splitbar div
for(var i = 0; i < scoreGrid.getView().columnSplits.length; i++) {
getEl(scoreGrid.getView().columnSplits[i].id).remove();
}
scoreGrid.getView().columnSplits = [];
scoreGrid.getView().indexMap = scoreGrid.getView().buildIndexMap();
scoreGrid.getView().render();
scoreGrid.getColumnModel().totalWidth = undefined;
var xml = loadXML(json.xml);
scoreGrid.getDataModel().loadData(xml);
stopwatch.stop();
alert("time consumed : " + stopwatch.getTime());
hideLoading();
}