PDA

View Full Version : Issue in Itemselector.



saurabh_agarwal15
11 Feb 2011, 3:15 AM
hi All,

I am a novice to ExtJs, but found it really nice to use and easy to understand. Thanks to the Sencha and most specifically these forums where I had always got an answer to my problems.

for the first time I am unable to find the answer to one of my problem:
the issue is:
I have a requirement which needs 2 multilist boxes along with the two buttons for to and fro motion of the members in these lists. I was able to implement the functionality on top of multilist easily, but then I came across an extension ItemSelector which has already implemented all these features in a more better way. Now the issue is, when i am using the itemselector, i have to be specific at one particular value(let say 'any'), I mean if a user selects 'any' from one list to another and tries to add another element in the to-list, i have to give a pop up message to him. But I am unable to do so.
Kindly help me.

Regards,
Saurabh Agarwal

Condor
11 Feb 2011, 5:03 AM
The MultiSelect component fires a change event every time the user adds or removes something from the right list.

You could use this event to show your message.

saurabh_agarwal15
12 Feb 2011, 10:59 AM
Hi,
Thanks for the quick reply.
I tried using it, i overrided the same method and I am able to hit the scenario but the problem is the element is still geting added to the list.
Find my code for your reference:



Ext.ux.ItemSelector.prototype.valueChanged = function(store) {
var record = null;
var values = [];

for (var i=0; i<store.getCount(); i++) {
if(store.getCount()>1){
record = store.getAt(i);
var val = record.get('value');
if(val.toLowerCase()=="any"){
Ext.Msg.alert("Error","Any not allowed if any other object is selected");
return false;
}
else{
values.push(record.get(this.valueField));
}
}
}
this.fireEvent('change', this, values.join(this.delimiter), this.hiddenField.dom.value);
this.hiddenField.dom.value = values.join(this.delimiter);
}

saurabh_agarwal15
13 Feb 2011, 9:23 PM
hi Condor,
Thanks for the reply. I am still facing the same issue. Kindly look into the code and let me know what wrong i am doing?

Regards,
Saurabh Agarwal

Condor
17 Feb 2011, 2:25 AM
The record(s) have already been moved when valueChanged is called.

You should be overriding fromTo() and toFrom() instead.