-
30 Sep 2012 1:55 AM #1
Answered: alerting for required field on screen load
Answered: alerting for required field on screen load
Hi all,
I have a combobox with allowBlank set to false. When the screen loads, by default the combobox does not have red color border. I want to make it red on screen load itself. Any ideas on this?
Code:Ext.define('GradeCombo', { extend: 'Ext.form.field.ComboBox', alias: 'widget.gradecombo', allowBlank: false, blankText: 'Grade is required', queryMode: 'local', valueField: 'id', displayField: 'name', });
-
Best Answer Posted by vietits
Try this:
Code:Ext.define('GradeCombo', { extend: 'Ext.form.field.ComboBox', alias: 'widget.gradecombo', allowBlank: false, blankText: 'Grade is required', queryMode: 'local', valueField: 'id', displayField: 'name', listeners: { render: function(){ this.validate(); } } });
-
30 Sep 2012 2:12 AM #2
Try this:
Code:Ext.define('GradeCombo', { extend: 'Ext.form.field.ComboBox', alias: 'widget.gradecombo', allowBlank: false, blankText: 'Grade is required', queryMode: 'local', valueField: 'id', displayField: 'name', listeners: { render: function(){ this.validate(); } } });
-
30 Sep 2012 3:05 AM #3
Thanks, that worked.
For some other combobox present in the screen, I want the first displayField text to be displayed in the combobox textfield when the screen loads for the first time. How to achieve that?
-
30 Sep 2012 11:49 AM #4Sencha User
- Join Date
- Dec 2009
- Location
- Enschede, The Netherlands
- Posts
- 327
- Vote Rating
- 11
- Answers
- 16
It would be better to open a new thread for a new question, IMHO. Especially if the original question might provoke more reactions, things might get quite cluttered.
How about this reasoning:
- On loading of the store,
- I want to fetch the first record
- And set it as my value.
Translating that to code:
Code:Ext.define('GradeCombo', { extend: 'Ext.form.field.ComboBox', alias: 'widget.gradecombo', allowBlank: false, blankText: 'Grade is required', queryMode: 'local', valueField: 'id', displayField: 'name', listeners: { load: function(){ this.setValue(this.store.getAt(0)); } } });
-
30 Jan 2013 8:06 AM #5
I have the opposite problem. All of my combobox seem to default to being marked with an error (with required field) as the message. This is when the form is first rendered before anyone types a thing. I'd like these combobox to perform like the textfields and datefields on the screen where they are marked as required when I tab through them and don't enter anything.
Strange (to me at least) ... if I click my button to form.reset() the red required messages go away. That makes me think something is going on before or when my form is rendered to try and validate it!


Reply With Quote
