Code:
DataSlotFilter = Ext.extend(Ext.Container, {
//autoScroll : true,
//autoHeight : true,
flex:2,
layout:'border',
initComponent: function(){
Ext.apply(this, {
});
DataSlotFilter.superclass.initComponent.apply(this, arguments);
},
onRender: function(){
DataSlotFilter.superclass.onRender.apply(this, arguments);
addRowTitles();
new Ext.form.TextField({
renderTo:this.getId(),
id:'dynamicConditions',
name:'dynamicConditions',
hidden:true
});
new Ext.form.TextField({
renderTo:this.getId(),
id:'dynamicColumns',
name:'dynamicColumns',
hidden:true
});
this.addRow();
},
reset : function(){
var count = this.items.length;
filter = this,
this.items.each(function(item,index,length) {
if(count > 2 && index > 0){
filter.remove(item);
count--;
}
});
this.items.get(1).reset();
this.doLayout();
},
addRow : function(){
var c = getFilterRowCfg();
this.add(c);
if(this.items.length == 4){
this.syncSize();
//this.setAutoScroll(true);
}
this.doLayout();
},
deleteRow : function(item){
var count = this.items.length;
if(count > 2){
this.remove(item);
count--;
/*if(count == 3){
//this.setAutoScroll(false);
}*/
}
if(count == 2) {
var rowId = this.items.get(1).getRowId();
var delDsBtn = Ext.getCmp('delDsRowBtn_'+rowId);
this.items.get(1).remove(7);
delDsBtn.destroy();
this.items.get(1).insert(7,getResetButtonCfg(rowId));
}
//this.syncSize();
this.doLayout(false,true);
},
insertRow : function(index){
var cfg = getFilterRowCfg();
this.insert(index,cfg);
if(this.items.length == 4){
this.syncSize();
this.setAutoScroll(true);
}
//remove reset button if multiple rows.
var rowId = this.items.get(1).getRowId();
var resetBtn = Ext.getCmp('resetDs_'+rowId);
var count = this.items.length;
if(count > 2 && !Ext.isEmpty(resetBtn)) {
this.items.get(1).remove(7);
resetBtn.destroy();
this.items.get(1).insert(7, getDelButtonCfg(rowId));
}
this.doLayout(false,true);
}
});
Ext.reg('DataSlotFilter', DataSlotFilter);
Ext.ns('Bm.component');
Bm.component.rowIdCounter = 0;
dsFilterRow = Ext.extend(Ext.Container,{ layout:'hbox',
layoutConfig:{
align : 'middle'
},
border : false,
autowidth : true,
autoHeight : true,
rowId : 0,
defaults : {
margins:'0 5 0 5'
},
flex:2,
style:"margin-bottom:5px;margin-top:5px;",
bodyStyle:'background:#ffffff',
initComponent: function(){
Ext.apply(this, {
});
dsFilterRow.superclass.initComponent.apply(this, arguments);
},
getRowId : function() {
return this.rowId;
},
onRender: function(){
dsFilterRow.superclass.onRender.apply(this, arguments);
},
reset: function() {
this.items.each(function(item,index,length) {
if(item.getXType() != 'button' && item.getXType() != 'panel' && item.getXType() != 'component'){
item.clearValue();
}
});
this.restore();
},
restore : function(){
var dsCmb = this.items.get(1);
dsCmb.setDisabled(true);
if(this.items.get(3).getXType() != 'dsValue'){
var field = {xtype:'dsValue',flex:2};
this.remove(3);
this.insertField(3, field);
}
},
insertField : function(index, field){
this.insert(index, field);
this.doLayout();
}
});
Ext.reg('dsFilterRow', dsFilterRow);