PDA

View Full Version : Combobox with static inline data in Ext Designer



mehran
4 Mar 2012, 10:53 PM
Hi,

Consider having a combobox in Ext Designer which we want to contain a list of fixed choices. I want to know if it is possible to assign the values to the combobox in Ext Designer?

Here are my current knowledge:
- One can add a store from "Data Stores" panel containing the desired inline data.
- We can assign the store to the combobox in the designer.
- Set the combobox's "queryMode" to "local" so user's responsiveness is improved.

My problem:
- When the combobox is clicked and opened, the "Loading..." blocker is shown and it never goes away.

At last, my question:
- How to implement a combobox with static-inline data in the Ext Designer? I know that it's pretty simple when we are not using the Ext Designer, which is not the point.

Regards,
Mehran

aconran
5 Mar 2012, 5:51 AM
Pass in an array of arrays for the store configuration.

mehran
5 Mar 2012, 6:11 AM
If you mean setting the "data" attribute of stores, then that's no help. Even though the given array will be shown in combobox but the "Loading..." blocker won't disappear.

aconran
5 Mar 2012, 6:23 AM
I mean setting the store attribute of the ComboBox

mehran
5 Mar 2012, 6:28 AM
As far as I know, setting the store for a combobox can only be done in constructor of the ui class (the one that designer creates and should not be modified). I'll be grateful if you could tell me how to set the store after the combobox is initialized?

aconran
5 Mar 2012, 6:33 AM
Setting the store attribute to something like ['Foo', 'bar'] should work but does not.
http://docs.sencha.com/ext-js/4-0/#!/api/Ext.form.field.ComboBox-cfg-store

This is because designer interprets this value as a storeId to link it to and as a string.



As far as I know, setting the store for a combobox can only be done in constructor of the ui class (the one that designer creates and should not be modified). I'll be grateful if you could tell me how to set the store after the combobox is initialized?

No, this can be done in the implementation class.
via


this.store =

inside of the initComponent block before the superclass impl is called.

mehran
5 Mar 2012, 7:12 AM
There's still a problem with your suggestion. The assignment needs to be done after "callParent", not before it.

aconran
5 Mar 2012, 8:49 AM
Why would it be done after? Once you invoke callParent you are dealing with properties, not configurations.

mehran
5 Mar 2012, 9:55 PM
I think you've missed some of the aspects of this problem:

1. The "this" pointer represents a top-level container while in most cases our combobox is not a top-level container (Don't forget that we were trying to reach the combobox's store not the top-level container's).
2. Before the "callParent" call, there's still no sign of combobox. It is only mentioned in the ui class constructor. Something like this:


Ext.define('MyApp.view.ui.MyWindow', {
extend: 'Ext.window.Window',


height: 250,
width: 400,
title: 'My Window',


initComponent: function() {
var me = this;


Ext.applyIf(me, {
items: [
{
xtype: 'combobox',
fieldLabel: 'Label'
}
]
});


me.callParent(arguments);
}
});

I must admit that I don't know of a way how to set a store for the combobox here (before the it is actually created). Please let me know if I'm mistaken and there is a way.

Thanks

aconran
7 Mar 2012, 1:31 PM
Promote the combobox to a class.

Then set the store before calling parent.