Ext.ux.maximgb.tg.EditorGridPanel
所形成的树形表格,如果当右侧数据更改后,会出现节点位置偏(左)移,这要怎么解决了,
解决方法:
在引入的js文件TreeGrid.js中,只要重写这些方法即可:
onAdd : function(ds, records, index)
{
Ext.ux.maximgb.tg.GridView.superclass.onAdd.call(this, ds, records, index);
if (this.mainWrap) {
//this.updateAllColumnWidths();
this.processRows(0);
}
},
onRemove : function(ds, record, index, isUpdate)
{
Ext.ux.maximgb.tg.GridView.superclass.onRemove.call(this, ds, record, index, isUpdate);
if(isUpdate !== true){
if (this.mainWrap) {
//this.updateAllColumnWidths();
this.processRows(0);
}
}
},
onUpdate : function(ds, record)
{
Ext.ux.maximgb.tg.GridView.superclass.onUpdate.call(this, ds, record);
if (this.mainWrap) {
//this.updateAllColumnWidths();
this.processRows(0);
}
},
在每个方法中加入以下代码即可:
this.grid.view.refresh();
重写后为:
onAdd : function(ds, records, index)
{
Ext.ux.maximgb.tg.GridView.superclass.onAdd.call(this, ds, records, index);
if (this.mainWrap) {
//this.updateAllColumnWidths();
this.processRows(0);
// add
this.grid.view.refresh();
}
},
onRemove : function(ds, record, index, isUpdate)
{
Ext.ux.maximgb.tg.GridView.superclass.onRemove.call(this, ds, record, index, isUpdate);
if(isUpdate !== true){
if (this.mainWrap) {
//this.updateAllColumnWidths();
this.processRows(0);
// add
this.grid.view.refresh();
}
}
},
onUpdate : function(ds, record)
{
Ext.ux.maximgb.tg.GridView.superclass.onUpdate.call(this, ds, record);
if (this.mainWrap) {
//this.updateAllColumnWidths();
this.processRows(0);
// add
this.grid.view.refresh();
}
},
即在添加、删除、更改后,刷新一遍即可!
另外在Grid中有时候会统计所有子节点的值进行汇总时,store中只有query()方法,但有时会有问题,出现统计子节点出现计算错误:
var mixedCollection=s.queryExact("_parent",record.get("_id"));
这个时候就要重写store中原的的方法query了:
store中原有方法query为:
query : function(property, value, anyMatch, caseSensitive){
var fn = this.createFilterFn(property, value, anyMatch, caseSensitive);
return fn ? this.queryBy(fn) : this.data.clone();
},
重写query方法,改名后(queryExact --自定义)为:
Ext.override(Ext.data.Store,{
queryExact : function(property, value, anyMatch, caseSensitive){
var fn = this.createFilterFn(property, value, anyMatch, caseSensitive, true);
return fn ? this.queryBy(fn) : this.data.clone();
}
});