Ext.form.ComboBox 表格下拉最终版本
2008-09-19 09:59
337 查看
总终效果如下:
源码:
/**
* 下拉表格ComboBoxGrid
* @extend Ext.form.ComboBox
*
* @author MSN/Email:onebodysoftware@hotmail.com
*/
ComboBoxGrid = function(cfg) {
Ext.apply(this, cfg);
ComboBoxGrid.superclass.constructor.call(this, {
editable : false, // 禁止手写及联想功能
mode : 'local',
triggerAction : 'all',
maxHeight : 500,
selectedClass : '',
onSelect : Ext.emptyFn,
emptyText : '请选择...',
gridWidth:600,
gridHeight : 180,
listAlign : 'tr-br',
listWidth : 300,
resizable : false,
grid:new MainGrid({
id:Ext.id(),
height : this.gridHeight || 180,
width :this.gridWidth || 600,
cm:this.cm,
sm:this.sm,
store:this.store,
detailActList:this.detailActList
})
});
};
Ext.extend(ComboBoxGrid, Ext.form.ComboBox, {
gridClk : function(grid, rowIndex, e) {
var record = grid.getStore().getAt(rowIndex);
var idValue = record.get(this.valueField);
var displayValue = record.get(this.hiddenName);
this.setRawValue(idValue);
this.setValue(displayValue);
this.collapse();
this.fireEvent('gridselected', grid.getRecord(rowIndex));
},
initLayout : function() {
this.grid.autoScroll = true;
this.grid.height = this.gridHeight;
this.grid.containerScroll = false;
this.grid.border = false;
this.listWidth = this.grid.width + 3;
},
initComponent : function() {
ComboBoxGrid.superclass.initComponent.call(this);
this.initLayout();
this.tplId = Ext.id();
this.tpl = '<div id="' + this.tplId + '" style="height:' + (this.gridHeight || 180)
+ '";overflow:hidden;"></div>';
//Add Event
this.addEvents('gridselected');
},
listeners : {
'expand' : {
fn : function() {
if (!this.grid.rendered && this.tplId) {
this.initLayout();
this.grid.render(this.tplId);
// this.store.reload();
if (this.store.getCount() == 0) {
this.store.add(new Ext.data.Record([{}]));
}
this.grid.on('rowclick', this.gridClk, this);
}
this.grid.show();
}
},
'render' : {
fn : function() {
}
},
'beforedestroy' : {
fn : function(cmp) {
this.purgeListeners();
this.grid.purgeListeners();
}
},
'collapse' : {
fn : function(cmp) {
/**
* 防止当store的记录为0时不出现下拉的状况
*/
if (this.grid.store.getCount() == 0) {
this.store.add(new Ext.data.Record([{}]));
}
}
}
}
});
持续改进中...
源码:
/**
* 下拉表格ComboBoxGrid
* @extend Ext.form.ComboBox
*
* @author MSN/Email:onebodysoftware@hotmail.com
*/
ComboBoxGrid = function(cfg) {
Ext.apply(this, cfg);
ComboBoxGrid.superclass.constructor.call(this, {
editable : false, // 禁止手写及联想功能
mode : 'local',
triggerAction : 'all',
maxHeight : 500,
selectedClass : '',
onSelect : Ext.emptyFn,
emptyText : '请选择...',
gridWidth:600,
gridHeight : 180,
listAlign : 'tr-br',
listWidth : 300,
resizable : false,
grid:new MainGrid({
id:Ext.id(),
height : this.gridHeight || 180,
width :this.gridWidth || 600,
cm:this.cm,
sm:this.sm,
store:this.store,
detailActList:this.detailActList
})
});
};
Ext.extend(ComboBoxGrid, Ext.form.ComboBox, {
gridClk : function(grid, rowIndex, e) {
var record = grid.getStore().getAt(rowIndex);
var idValue = record.get(this.valueField);
var displayValue = record.get(this.hiddenName);
this.setRawValue(idValue);
this.setValue(displayValue);
this.collapse();
this.fireEvent('gridselected', grid.getRecord(rowIndex));
},
initLayout : function() {
this.grid.autoScroll = true;
this.grid.height = this.gridHeight;
this.grid.containerScroll = false;
this.grid.border = false;
this.listWidth = this.grid.width + 3;
},
initComponent : function() {
ComboBoxGrid.superclass.initComponent.call(this);
this.initLayout();
this.tplId = Ext.id();
this.tpl = '<div id="' + this.tplId + '" style="height:' + (this.gridHeight || 180)
+ '";overflow:hidden;"></div>';
//Add Event
this.addEvents('gridselected');
},
listeners : {
'expand' : {
fn : function() {
if (!this.grid.rendered && this.tplId) {
this.initLayout();
this.grid.render(this.tplId);
// this.store.reload();
if (this.store.getCount() == 0) {
this.store.add(new Ext.data.Record([{}]));
}
this.grid.on('rowclick', this.gridClk, this);
}
this.grid.show();
}
},
'render' : {
fn : function() {
}
},
'beforedestroy' : {
fn : function(cmp) {
this.purgeListeners();
this.grid.purgeListeners();
}
},
'collapse' : {
fn : function(cmp) {
/**
* 防止当store的记录为0时不出现下拉的状况
*/
if (this.grid.store.getCount() == 0) {
this.store.add(new Ext.data.Record([{}]));
}
}
}
}
});
持续改进中...
相关文章推荐
- Ext.form中的combobox一旦设hideTrigger:true不让下拉按钮隐藏
- Ext.form.ComboBox 动态加载数据后设置下拉选项
- 如果使用Ext.form.ComboBox 作为editor,并设置了store,在选择后,在表格单元中显示的是store中的displayfield 而不是valuefield
- Ext.form.ComboBox简单用法
- Ext.form.ComboBox显示错误的问题
- Ext.form.ComboBox 远程模式的基本定义
- 给Ext.form.ComboBox设置默认选中某项
- Ext comboBoxTree (完整的数据加载)--下拉列表里边是树结构
- 『转』Ext.form.ComboBox的各种属性、方法与事件
- Ext下拉 ComboBox多选拓展代码(超好用)
- Ext.form.ComboBox 属性详解(见注释)及使用方法
- 一款不错的多选下拉列表利器—— Ext.ux.form.SuperBoxSelect
- Ext.form.ComboBox最常用的一些属性和方法
- Ext.form.ComboBox调用store.filterBy失效问题
- [导入]继承Ext.form.TriggerField,实现树下拉选择(新增示例下载)
- EXTJS学习系列提高篇:第二十六篇(转载)作者殷良胜,ext2.2打造Ext.form.ComboBox系列--静态绑定
- Ext.form.ComboBox 基本定义
- Extjs 多选下拉框 Ext.ux.form.LovCombo默认选择及其它BUG修复版支持多选/全选/全不选ext3.x
- 如何设置comboBox下拉框的大小,并在下拉框中画上类式excel的表格???
- Ext.form.field.ComboBox示例