-
21 Apr 2008 10:25 PM #21
Forgive me, it is complex to state ideas in foreign language in five oclock of mornings, after ten hours of programming =)
I spoke about a new option which allow to show long lines in the dropping out list and short when i check some long items:
|[X] Long Name1 - Long Description1 |
|[ ] Long Name2 - Long Description3 |
|[X] Long Name3 - Long Description3 |
-------------------------------------
And when I shall choose some elements, they will be shown as:
[ Short Name1, Short Name3 |V|]
Typycal record from combo-store conteins: id, long_name, short_name
And now we have displayField:long_name for items in dropdown list, selectedField
hort_name for checked items in checkbox field-= miu-miu =-
Linux, Perl, GNU, Open Source, Ajax, Ubuntu 9.04
-
22 Apr 2008 12:50 AM #22
Oh, I see. Have you also modified beforequery code? The original plays nicely with typing and subsequent dropdown filtering. If you haven't then you deprive yourself, and your users, of convenient keyboard input.
Any demo/code I can test?Jozef Sakalos, aka Saki
A lot of valuable info at:
Saki's Extensions and Plugins
Saki's Extensions and Plugins Docs
Saki's Examples, Latest: Grid in Card Layout
Saki's Blog, Featured: Writing a Big Application in Ext, Latest: Grid MultiSearch Plugin Video
-
6 May 2008 9:32 AM #23
Hi Saki,
I like your lovcombo, it's really good extension, thanks for sharing
I've found some issues, maybe you have already fixed them or maybe it's my fault, I have to admit that I haven't check the source code too much...
First example that does not work for me, if I do not specify valueField, I can not select values (maybe it's a feature):
2)If then I add the valueField to the config, I have problem selecting the data containing "()"...PHP Code:var lc = new Ext.ux.form.LovCombo({
id:'lovcombo'
,renderTo:'lovcomboct'
,width:300
,hideOnSelect:false
,store:new Ext.data.SimpleStore({
fields:[{name:'id'}]
,data:[
['1 ()']
,['11 ()']
,['2']
,['22']
,['3']
]
})
,triggerAction:'all'
,displayField:'id'
,mode:'local'
});
I'd like only to know if I'm doing something wrongPHP Code:var lc = new Ext.ux.form.LovCombo({
id:'lovcombo'
,renderTo:'lovcomboct'
,width:300
,hideOnSelect:false
,store:new Ext.data.SimpleStore({
fields:[{name:'id'}]
,data:[
['1 ()']
,['11 ()']
,['2']
,['22']
,['3']
]
})
,triggerAction:'all'
,valueField:'id'
,displayField:'id'
,mode:'local'
});

Thanks for your help and for this beautifull extension.
-
6 May 2008 9:36 AM #24
Re 1: You need both valueField and displayField.
Re 2: You need 2d array, e.g. [[1, '1 ()'],[11, '11 ()']]Jozef Sakalos, aka Saki
A lot of valuable info at:
Saki's Extensions and Plugins
Saki's Extensions and Plugins Docs
Saki's Examples, Latest: Grid in Card Layout
Saki's Blog, Featured: Writing a Big Application in Ext, Latest: Grid MultiSearch Plugin Video
-
6 May 2008 9:37 AM #25Jozef Sakalos, aka Saki
A lot of valuable info at:
Saki's Extensions and Plugins
Saki's Extensions and Plugins Docs
Saki's Examples, Latest: Grid in Card Layout
Saki's Blog, Featured: Writing a Big Application in Ext, Latest: Grid MultiSearch Plugin Video
-
6 May 2008 4:01 PM #26
hey I just found your site (extjs.eu) today and I am really liking these additions to ExtJS. I found a problem with the onRealBlur event for the LovCombo though. Due to the RegExp matching in that function, if you have an unclicked option that is contained inside a clicked option (e.g. 'no' is inside 'another') then when you blur, the unclicked option will suddenly appear in the value list.
PHP Code:var re = new RegExp(r.get(this.displayField));
if(v.match(re)) {
va.push(r.get(this.valueField));
}
-
6 May 2008 4:55 PM #27
Post please a showcase so I can debug it. Or you have a proposed patch?
Jozef Sakalos, aka Saki
A lot of valuable info at:
Saki's Extensions and Plugins
Saki's Extensions and Plugins Docs
Saki's Examples, Latest: Grid in Card Layout
Saki's Blog, Featured: Writing a Big Application in Ext, Latest: Grid MultiSearch Plugin Video
-
7 May 2008 5:55 AM #28
Hi Saki,
I wanted to use your lovcombo instead a normal combobox, and I could not change the data for the store in my code, because the same data are used in different context (store load data from server).
1) So I've tried to make it works also with simple data like the following:
2) and without specify the valueField (so that if not specified, I suppose that the valueField is the same of the displayField.)PHP Code:var data = [
['15 (prova)']
,['11 ()']
,['2']
,['22']
,['3']
];
For me it works, but I have not tested a lot, and I have some problem in case the store is loaded remotely and you want to preset a value in the combo, the first time you expand the combo, the preselected element it does not appear checked (I have a workaround in my code, in the load event of the store, I change the mode of the lovcombo instance from remote to local and then I call setValue()).
This is the code changes:
This is the complete code:PHP Code:,charsToEscape: ['(',')','[', ']', '^', '|', '?', '*', '+', '{', '}']//to complete
,initComponent:function() {
// template with checkbox
if(!this.tpl) {
this.tpl =
'<tpl for=".">'
+'<div class="x-combo-list-item">'
+'<img src="' + Ext.BLANK_IMAGE_URL + '" '
+'class="ux-lovcombo-icon ux-lovcombo-icon-'
+'{[values.' + this.checkField + '?"checked":"unchecked"' + ']}">'
+'<div class="ux-lovcombo-item-text">{' + this.displayField + '}</div>'
+'</div>'
+'</tpl>'
;
}
//************************
if(!this.valueField)
this.valueField = this.displayField;
//************************
// call parent
Ext.ux.form.LovCombo.superclass.initComponent.apply(this, arguments);
// install internal event handlers
this.on({
scope:this
,beforequery:this.onBeforeQuery
,blur:this.onRealBlur
});
// remove selection from input field
this.onLoad = this.onLoad.createSequence(function() {
if(this.el) {
var v = this.el.dom.value;
this.el.dom.value = '';
this.el.dom.value = v;
}
});
} // e/o function initComponent
,onRealBlur:function() {
this.list.hide();
var v = this.getRawValue();
var va = [];
this.store.clearFilter();
this.store.each(function(r) {
//***********************
var innerRe= this.escapeStringValue(r.get(this.displayField));
//***********************
var re = new RegExp(innerRe);
if(v.match(re)) {
va.push(r.get(this.valueField));
}
}, this);
this.setValue(va.join(this.separator));
} // eo function onRealBlur
,setValue:function(v) {
if(v) {
v = '' + v;
if(this.valueField) {
this.store.clearFilter();
this.store.each(function(r) {
//*****************************
var stringValue = this.escapeStringValue(r.get(this.valueField));
var checked = !(!v.match('(^|' + this.separator + ')' + stringValue +'(' + this.separator + '|$)'));
//******************************
r.set(this.checkField, checked);
}, this);
this.value = this.getCheckedValue();
this.setRawValue(this.getCheckedDisplay());
if(this.hiddenField) {
this.hiddenField.value = this.value;
}
}
else {
this.value = v;
this.setRawValue(v);
if(this.hiddenField) {
this.hiddenField.value = v;
}
}
}
else {
this.clearValue();
}
} // eo function setValue
,escapeStringValue: function(stringValue) {
for(var i = 0; i < this.charsToEscape.length; i++) {
var charToEscape = this.charsToEscape[i];
var replaceWith = "\\" + charToEscape;
stringValue = '' + stringValue;
stringValue = stringValue.replace(charToEscape, replaceWith);
}
return stringValue;
}
[PHP]
// vim: ts=4
w=4:nu:fdc=4:nospell
/**
* Ext.ux.form.LovCombo, List of Values Combo
*
* @author Ing. Jozef SakLast edited by mabello; 7 May 2008 at 6:29 AM. Reason: Fix of my code to work also with your example
-
7 May 2008 6:26 AM #29
Fix:
Now it works also with your examplePHP Code:,escapeStringValue: function(stringValue) {
for(var i = 0; i < this.charsToEscape.length; i++) {
var charToEscape = this.charsToEscape[i];
var replaceWith = "\\" + charToEscape;
stringValue = '' + stringValue;
stringValue = stringValue.replace(charToEscape, replaceWith);
}
return stringValue;
}
(Updated my prevoius post)
-
7 May 2008 6:57 AM #30
Function to escape regular expression special characters doesn't belong to this extension in fact as it is more general. I was playing a bit with it and this is what I came out with:
It defines static method escape of RegExp object and is called as:PHP Code:RegExp.escape = function(s) {
if('string' !== typeof s) {
return s;
}
// see attached image for line that should come here. Forum strips backslashes
}; // eo function escape
Play please a bit with it; I'm not 100% sure if I've included all RegExp special characters.PHP Code:var s = RegExp.escape('1 ()');
As to, valueField: I wouldn't hard code it in the extension as other users may have reversed preferences. It can be configured from outside anyway.Jozef Sakalos, aka Saki
A lot of valuable info at:
Saki's Extensions and Plugins
Saki's Extensions and Plugins Docs
Saki's Examples, Latest: Grid in Card Layout
Saki's Blog, Featured: Writing a Big Application in Ext, Latest: Grid MultiSearch Plugin Video



Reply With Quote