PDA

View Full Version : Combo field validation



samarth
15 Oct 2013, 9:47 PM
Hi folks,
I am using ExtJS 3.4. I have two combo box with hour value from 0 to 23. I need a help that when i selected a value in one combo box like 5 then in the another combo box 5 to 23 have to displayed 0-5 should not be displayed. Please help me out in this issue. I have hard coded the values in combo box by using Value attribute.



Thanks in advance
Samarth Manjunth

samarth
15 Oct 2013, 9:54 PM
Hi folks,
I am using ExtJS 3.4. I have two combo box with hour value from 0 to 23. I need a help that when i selected a value in one combo box like 5 then in the another combo box 5 to 23 have to displayed 0-5 should not be displayed. Please help me out in this issue. I have hard coded the values in combo box by using Value attribute.



Thanks in advance
Samarth Manjunth

i have included my code with this


xtype:'combo',
width:70,
emptyText : 'HH',
triggerAction:'all',
forceSelection : true,
selectOnFocus : true,
editable:false,
mode:'local',
id:'hourStart',
store:['00','01','02','03','04','05','06','07','08','09','10','11','12','13','14','15','16','17','18','19','20','21','22','23']




and same type in another combo.

slemmon
17 Oct 2013, 3:29 PM
In Combobox A you could set a change or valid event handler to take the value from Combobox A and use it in a filterBy method on the store on Combobox B.

In the filter function you'd want to see if the value being evaluate by the filterBy function is the same or higher than the value from Combobox A. Given your values are '05' and so forth you may need to use javascript's parseInt method for the evaluation.

samarth
17 Oct 2013, 8:52 PM
Hi slemmon,
Thanks for your reply. Can you please share an example code.?

In Combobox A you could set a change or valid event handler to take the value from Combobox A and use it in a filterBy method on the store on Combobox B.

In the filter function you'd want to see if the value being evaluate by the filterBy function is the same or higher than the value from Combobox A. Given your values are '05' and so forth you may need to use javascript's parseInt method for the evaluation.

slemmon
21 Oct 2013, 3:20 PM
Ok. See if this helps:

https://fiddle.sencha.com/#fiddle/13d

I changed the listener a little bit from my previous reply, but effectively the same technique and is the same outcome. You might have to tweak it some to accommodate times where you want combo 2 cleared / invalidated based on new selections from Combo1.

samarth
21 Oct 2013, 8:29 PM
Dear slemmon,
Thank you for your valuable reply to me. I will try to implement this scenario.


Ok. See if this helps:

https://fiddle.sencha.com/#fiddle/13d

I changed the listener a little bit from my previous reply, but effectively the same technique and is the same outcome. You might have to tweak it some to accommodate times where you want combo 2 cleared / invalidated based on new selections from Combo1.