1. #1
    Sencha User
    Join Date
    Jul 2013
    Location
    Mysore, Karnataka, India
    Posts
    85
    Vote Rating
    6
    sanjayon19 is on a distinguished road

      0  

    Default ExtJS 4.2.1 MVC : ComboBox Controller

    ExtJS 4.2.1 MVC : ComboBox Controller


    Hi all,

    I've 2 ComboBoxes on my screen. Each desgined as per MVC approach. I'm getting the data for the first ComboBox from Database in JSON format.

    Now the question is, The Second ComboBox need to be loaded based on the element selected in the First ComboBox. i.e, The item selected in the First Combo Box has to be accessed from the controller of the second combo Box and the selected item has to be appended to the URL in the Store of the second combo box.

    Example : The URL to get the data for the Second Combo Box is
    URL : /app/data/getValueList.jsp?attribute='<Item_Selected_In_First_Combo_Box>'

    How to get this done? I need to get the item selected in the First combo and append that to the URL of the Second Combo. The code is in MVC. Each combo box have its own View, Store and Controller.

    Please let me know how we can do this?

  2. #2
    Sencha User existdissolve's Avatar
    Join Date
    Jan 2010
    Location
    Kansas
    Posts
    522
    Vote Rating
    85
    existdissolve is just really nice existdissolve is just really nice existdissolve is just really nice existdissolve is just really nice existdissolve is just really nice

      1  

    Default


    Quote Originally Posted by sanjayon19 View Post
    Hi all,

    I've 2 ComboBoxes on my screen. Each desgined as per MVC approach. I'm getting the data for the first ComboBox from Database in JSON format.

    Now the question is, The Second ComboBox need to be loaded based on the element selected in the First ComboBox. i.e, The item selected in the First Combo Box has to be accessed from the controller of the second combo Box and the selected item has to be appended to the URL in the Store of the second combo box.

    Example : The URL to get the data for the Second Combo Box is
    URL : /app/data/getValueList.jsp?attribute='<Item_Selected_In_First_Combo_Box>'

    How to get this done? I need to get the item selected in the First combo and append that to the URL of the Second Combo. The code is in MVC. Each combo box have its own View, Store and Controller.

    Please let me know how we can do this?
    One approach I often take is to use the beforequery event on the combobox. In the listener, I'll lookup the value from the first combo and add it as a filter to the store. In your case, you could just update extraParams of the store's proxy. Using the approach, you could also do a pre-check to make sure that you have a valid value in the first combobox before making a query on the second.

  3. #3
    Sencha User
    Join Date
    Jul 2013
    Location
    Mysore, Karnataka, India
    Posts
    85
    Vote Rating
    6
    sanjayon19 is on a distinguished road

      0  

    Default


    Thanks for suggesting the approach.

    I'm new to ExtJS4. Can you please share a sample example so that I can understand?

  4. #4
    Sencha User existdissolve's Avatar
    Join Date
    Jan 2010
    Location
    Kansas
    Posts
    522
    Vote Rating
    85
    existdissolve is just really nice existdissolve is just really nice existdissolve is just really nice existdissolve is just really nice existdissolve is just really nice

      1  

    Default


    Quote Originally Posted by sanjayon19 View Post
    Thanks for suggesting the approach.

    I'm new to ExtJS4. Can you please share a sample example so that I can understand?
    I've put together a MVC-ish Fiddle that shows how this could be done. Look at the "Combos.js" controller to see what I was talking about.



    Hmm, so it won't render in the forum. Be sure to view it in Sencha Fiddle itself.

    Thanks!

  5. #5
    Sencha User
    Join Date
    Jul 2013
    Location
    Mysore, Karnataka, India
    Posts
    85
    Vote Rating
    6
    sanjayon19 is on a distinguished road

      0  

    Default Thanks a lot :)

    Thanks a lot :)


    The example is clearsy stated. Thanks a lot for this,

    Can you please brief me about my few questions?

    1) Can we get the access of any component in any of the controller?
    2) In the Controller you gave as example, you are trying to access the Parent component oc Combo1 right?
    3) What is queryplan in Controller? Is it just a variable? does it have any value.?
    4) How to access/read the value of any component in ExtJS 4.2.1?

    I'm new to ExtJS.
    Request you to give a little more detail so that I can understand clearly.

    Thanks again for your example.

  6. #6
    Sencha User
    Join Date
    Jul 2013
    Location
    Mysore, Karnataka, India
    Posts
    85
    Vote Rating
    6
    sanjayon19 is on a distinguished road

      0  

    Default Need little help

    Need little help


    Can you please tell me what is queryplan in Controller?

    I got access of View but when I'm trying to set the value for Parameters, I'm getting errors.

    I'm executing
    combo.getStore().getProxy().setExtraParam('attribute', value);

    but getting error like this.
    Line: 21
    Error: Unable to get value of the property 'apply': object is null or undefined.errorlog.jpg

  7. #7
    Sencha User existdissolve's Avatar
    Join Date
    Jan 2010
    Location
    Kansas
    Posts
    522
    Vote Rating
    85
    existdissolve is just really nice existdissolve is just really nice existdissolve is just really nice existdissolve is just really nice existdissolve is just really nice

      1  

    Default


    Quote Originally Posted by sanjayon19 View Post
    The example is clearsy stated. Thanks a lot for this,

    Can you please brief me about my few questions?

    1) Can we get the access of any component in any of the controller?
    2) In the Controller you gave as example, you are trying to access the Parent component oc Combo1 right?
    3) What is queryplan in Controller? Is it just a variable? does it have any value.?
    4) How to access/read the value of any component in ExtJS 4.2.1?

    I'm new to ExtJS.
    Request you to give a little more detail so that I can understand clearly.

    Thanks again for your example.
    1.) Yes. You can use refs or ComponentQuery
    2.) It's not really a "parent" component, but yes.
    3.) Look at the beforequery documentation. It explains the queryplan: http://docs.sencha.com/extjs/4.2.1/#!/api/Ext.form.field.ComboBox-event-beforequery
    4
    .) I'm not sure what you mean by "value" of any component. A lot of components don't have "values". However, to access components, you can use a number of approaches.
    1. In your controller, you can create a "ref" and then use the generated getter to retrieve the component.
    2. If the desired component is hierarchically related to a component to which you already have a reference, you can use the up() and down() to traverse the component tree
    3. Use ComponentQuery
    Before pasting your code, see if you can make a working example using Sencha Fiddle: https://fiddle.sencha.com/

    Not only will it let everyone see what you're talking about with their own eyes, but it also makes debugging your issue 19 billion times easier

    Embedding your newly created Fiddle is super-easy: Using Sencha Fiddle in the Forums

  8. #8
    Sencha User
    Join Date
    Jul 2013
    Location
    Mysore, Karnataka, India
    Posts
    85
    Vote Rating
    6
    sanjayon19 is on a distinguished road

      0  

    Default Bingo.....

    Bingo.....


    Its working now.

    Thanks for your descriptive explanation.

    Now, I'm able to append the parameter to the query and send the query to DB.
    But its happening for the first time only(Without refreshing).

    If I select another attribute in the First Combo and click on the second combo to fetch the value, it seems the ajax call with new attribute appended to the URL is not being sent.

    I put logs in the Backend code and I was able to see only one request(first request) came with the first attribute.

    Can you please tell me what else could be the problem?
    Do I need to specify some config to refresh the combo?

  9. #9
    Sencha User existdissolve's Avatar
    Join Date
    Jan 2010
    Location
    Kansas
    Posts
    522
    Vote Rating
    85
    existdissolve is just really nice existdissolve is just really nice existdissolve is just really nice existdissolve is just really nice existdissolve is just really nice

      1  

    Default


    Quote Originally Posted by sanjayon19 View Post
    Its working now.

    Thanks for your descriptive explanation.

    Now, I'm able to append the parameter to the query and send the query to DB.
    But its happening for the first time only(Without refreshing).

    If I select another attribute in the First Combo and click on the second combo to fetch the value, it seems the ajax call with new attribute appended to the URL is not being sent.

    I put logs in the Backend code and I was able to see only one request(first request) came with the first attribute.

    Can you please tell me what else could be the problem?
    Do I need to specify some config to refresh the combo?
    The reason it's only loading the first time is that the combo will cache the results and only re-query if the query has changed.

    To get around this, you can either set queryCaching to false (default is true), or you can set up something to clear the value in the 2nd combobox everytime a selection is made in the first.

    Personally, I use the second approach as I like to take advantage of the queryCaching, but still be able to force a requery when the selection in the first combo box changes.
    Before pasting your code, see if you can make a working example using Sencha Fiddle: https://fiddle.sencha.com/

    Not only will it let everyone see what you're talking about with their own eyes, but it also makes debugging your issue 19 billion times easier

    Embedding your newly created Fiddle is super-easy: Using Sencha Fiddle in the Forums

  10. #10
    Sencha User
    Join Date
    Jul 2013
    Location
    Mysore, Karnataka, India
    Posts
    85
    Vote Rating
    6
    sanjayon19 is on a distinguished road

      0  

    Default Thank You :)

    Thank You :)


    Yeah.. I followed the 2nd approach and its working. Thanks for the help.

    Based on the change in the 1st Combo, I'm resetting and then reloading the 2nd ComboBox.

    Thanks for your help

Thread Participants: 1

Tags for this Thread

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi