You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
DS7/DSWeb/Areas/CommMng/Viewsjs/Comm/GridComboBoxList.js

81 lines
2.0 KiB
JavaScript

3 years ago
/**
* v1.2.2 2012-05-07
* author: Mac_J, <EFBFBD>ġ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*/
Ext.define('Ext.ux.view.GridComboBoxList', {
extend : 'Ext.view.AbstractView',
alias : 'widget.gridcombolist',
alternateClassName : 'Ext.GridComboBoxList',
// 2012-05-07 Ext4.1<EFBFBD>µ<EFBFBD>Bug<EFBFBD>Ľ<EFBFBD><EFBFBD><EFBFBD>
renderTpl : [ '<div class="list-ct" style="border: 1px solid #99BBE8"></div>' ],
//renderTpl : [ '<div class="list-ct" style="border: 1px solid #99BBE8"></div>' ],
initComponent : function() {
var me = this;
// 2012-05-07 Ext4.1<EFBFBD>µ<EFBFBD>Bug<EFBFBD>Ľ<EFBFBD><EFBFBD><EFBFBD>
me.itemSelector = "div.list-ct";
//me.itemSelector = ".";
me.tpl = Ext.create('Ext.XTemplate');
me.callParent();
Ext.applyIf(me.renderSelectors, {
listEl : '.list-ct'
});
me.gridCfg.border = false;
me.gridCfg.store = me.store;
me.grid = Ext.create('Ext.grid.Panel', me.gridCfg);
me.grid.store.addListener({
beforeload : function() {
me.owner.loading = true;
},
load : function() {
me.owner.loading = false;
}
});
var sm = me.grid.getSelectionModel();
sm.addListener('selectionchange', function(a, sl) {
var cbx = me.owner;
if (cbx.loading)
return;
var sv = cbx.multiSelect? cbx.getValue():{};
// sv = {}
var EA = Ext.Array, vf = cbx.valueField;
// al = [ 'G', 'Y', 'B' ]
var al = EA.map(me.grid.store.data.items, function(r) {
return r.data[vf];
});
var cs = EA.map(sl, function(r) {
var d = r.data;
if(d){
var k = d[vf];
sv[k] = d;
return k;
}
});
// cs = [ 'G' ]
var rl = EA.difference(al, cs);
EA.each(rl, function(r) {
delete sv[r];
});
cbx.setValue(sv);
});
sm.addListener('select', function(m, r, i) {
var cbx = me.owner;
if (cbx.loading)
return;
if(!cbx.multiSelect)
cbx.collapse();
});
},
onRender : function() {
this.callParent(arguments);
this.grid.render(this.listEl);
},
bindStore : function(store, initial) {
this.callParent(arguments);
if(this.grid)
this.grid.bindStore(store, initial);
},
onDestroy : function() {
Ext.destroyMembers(this, 'grid', 'listEl');
this.callParent();
}
});