Page 1 of 2 12 LastLast
Results 1 to 10 of 17

Thread: Dynamically setting navigation menus

  1. #1
    Sencha User Alphawolf's Avatar
    Join Date
    Jul 2007
    Posts
    8
    Vote Rating
    0
      0  

    Default Dynamically setting navigation menus

    Hey there,

    I just had a look at the Sink example and was wondering if it's possible to set the navigation dynamically from a source like JSON-P or sth.?

    Currently the navigation contents are loading from a static JS like:
    Code:
    ns.Structure = [{
        text: 'Functions',
        cls: 'launchscreen',
        items: [{
            text: 'Buttons',
            card: null,
            source: 'dynamic1'
        }]
    },
    ...];
    and then called with:
    Code:
    navigationItems: ns.Structure,
    So, is it possible to load the submenu elements (e.g. dynamic1) from a dynamic source instead of a static JS file?

    Thanks in advance!
    :|

  2. #2
    Sencha Premium User mrsunshine's Avatar
    Join Date
    Sep 2008
    Location
    Germany - Darmstadt
    Posts
    693
    Vote Rating
    13
      0  

    Default

    off course, you can.

    you can load a configuration and add the items with the .add(yourconfig) method to a Ext.Nestedlist or what you need

  3. #3
    Sencha User Alphawolf's Avatar
    Join Date
    Jul 2007
    Posts
    8
    Vote Rating
    0
      0  

    Default

    Hey Nils,

    thanks so far. Unfortunately the API docs return 404 all over for me when trying to access docs for the add() method. Moreover, I cannot find any API docs for Ext.ux.UniversalUI which I use on Sencha Touch to render the menu.

    Here's what I have so far: http://wpseek.com/mobile/js/wpseek-m.js (wpseek.Main.sendRequest)
    And here's the structure I'd like to add the menu items to: http://wpseek.com/mobile/js/structure.js

    I'm trying to add them with:
    Code:
    wpseek.Structure.add({text: 'test'});
    :|

  4. #4
    Sencha User
    Join Date
    Mar 2007
    Location
    Haarlem, Netherlands
    Posts
    1,243
    Vote Rating
    11
      0  

    Default

    The UniversalUI class was something we didn't want to put into the main library and docs at time of release. We are working on some very elegant ways to manage layouts across tablets and phones and didn't want people to rely on UniversalUI just yet. I can't guarantee the API for it won't change soon.

  5. #5
    Sencha User Alphawolf's Avatar
    Join Date
    Jul 2007
    Posts
    8
    Vote Rating
    0
      0  

    Default

    Alright, thanks for the reply. So I should freeze the navigation part for now until you updated the API?
    :|

  6. #6
    Sencha User
    Join Date
    Mar 2007
    Location
    Haarlem, Netherlands
    Posts
    1,243
    Vote Rating
    11
      0  

    Default

    No you can still use it. You might have to change your code a little when you update to one of the upcoming versions. It won't probably be that much different. For you to add temporary functionality to it might not be worth it though since they are almost guaranteed to break once I change the class. .

  7. #7
    Ext User
    Join Date
    Jun 2010
    Posts
    9
    Vote Rating
    0
      0  

    Default

    Hello there.

    I am also trying to get a dynamic navigation menu to work and after looking at the documentation, I figured that adding items to the nestedList would be the way to go, just like suggested up there:

    Quote Originally Posted by mrsunshine View Post
    add the items with the .add(yourconfig) method to a Ext.Nestedlist or what you need
    But, somehow this does not seem to work. After trying in my app for a while I took a step back and tried to modify the Nested List Example from the Sencha Touch beta with one simple line (after the list is created):

    Code:
    nestedList.add({
          text : 'Option D'
    });
    No success here. Then I thought, that lazy rendering might be a reason, and I added:

    Code:
    nestedList.doLayout();
    Still no luck. Any suggestions on what I am missing? Or may this be a bug in the nestedList component?
    Ideas would be greatly appreciated.

    Thanks
    M

  8. #8
    Sencha User
    Join Date
    Mar 2007
    Location
    Haarlem, Netherlands
    Posts
    1,243
    Vote Rating
    11
      0  

    Default

    The example was not designed to handle dynamic loading of navigation items. The UniversalUI class was more a proof of concept than an actual class to be used. That is why it was in an example and not in the library itself. Structure is just an array that is being passed to the NestedList constructor on instantation. It doesnt update itself when you modify that array. I would suggest starting from scratch and instantiating your own NestedList. If you look in the source code for NestedList you can find a method called setList. You can pass it an object that contains text and items properties. This is what you want to call after your ajax request comes back.

    I am saving this thread and will make sure that we provide an easy way to achieve what you are trying to do in an upcoming release.

  9. #9
    Ext User
    Join Date
    Jun 2010
    Posts
    9
    Vote Rating
    0
      0  

    Default

    Hi Tommy,

    thanks for pointing me to setList(), it serves quite well as a good work-around for now. I guess I was relying a bit too much on the API Documentation and didn't check for other methods available in the source.

    By the way, I think that Sensa Touch as a whole is an excellent piece of work. While working myself into the framework (I have no previous experience with Ext.js) I sometimes had to chuckle, because I couldn't believe how easy you make some of the more annoying tasks. Thanks a great deal for that.

  10. #10
    Ext User
    Join Date
    Jun 2010
    Posts
    4
    Vote Rating
    0
      0  

    Default

    Could you please post an example of using setList() ?

    Trying to do exactly the same (set nestedList items dynamically using ajax data).

    Will the listeners initially set on the nestedList still work? We have setup a listener to change the toolbar title when a list item is clicked.

Page 1 of 2 12 LastLast

Similar Threads

  1. [OPEN] [CLOSED] Setting modal on Dialog does not disable tab navigation
    By appian_it in forum Ext GWT: Bugs (2.x)
    Replies: 4
    Last Post: 22 Sep 2009, 7:05 AM
  2. Setting left value dynamically
    By emredagli in forum Ext 2.x: Help & Discussion
    Replies: 2
    Last Post: 1 Sep 2008, 11:10 PM
  3. Setting tabs dynamically help
    By GraemeBaillie in forum Ext 2.x: Help & Discussion
    Replies: 1
    Last Post: 20 Jun 2008, 2:05 AM
  4. dynamically adding and removing menus
    By holli in forum Ext 1.x: Help & Discussion
    Replies: 0
    Last Post: 23 Oct 2007, 2:10 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •