How to move items of the panelBar

10 posts, 0 answers
  1. aspUser
    aspUser avatar
    5 posts
    Member since:
    Jun 2011

    Posted 30 Jun 2011 Link to this post

    Hello!

    Please, can you tell me: how can i move 1-level items of the panelBar, when one of them was clicked?
    For example:
    panelBar:
    item 1
    item 2
    item 3
    When i click on the item, for example, "item 2", i want the result:
    item 1
    item 3
    item 2
    Note: this result i want get without postback, but after postback this result must be (perhaps, must use trackChanges-commitChanges).

    Thank you.
  2. Nikolay Tsenkov
    Admin
    Nikolay Tsenkov avatar
    734 posts

    Posted 30 Jun 2011 Link to this post

    Hi Aspuser,

    You can handle the ClientItemClicked event and get the clicked item (args.get_item()) and then to insert the item in the next/previous position in the items collection (root.get_items().insert(index, item)).


    Regards,
    Nikolay Tsenkov
    the Telerik team

    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. aspUser
    aspUser avatar
    5 posts
    Member since:
    Jun 2011

    Posted 01 Jul 2011 Link to this post

    Hello, Nikolay. Thank you for your reply!
    Earlier i have tried the strategy, which you have described. It have a problem.
    Here is my code of the method, which handle "OnClientItemClicked" event of the panelBar:
            
    onItemClicked = function(sender, eventArgs)
    {
        var panelBar = $find("<%= rPanelBarMenu.ClientID %>");
        var itemsPanelBar = panelBar.get_items();
        var selectedItem = eventArgs.get_item();
        if (selectedItem.get_index() == itemsPanelBar.get_count() - 1) {
            return;
        }      
        panelBar.trackChanges();
        // insert selected item in the end of collection
        panelBar.get_items().insert(itemsPanelBar.get_count(), selectedItem); // this is problem string!!!
        // delete selected item with the old index
        panelBar.get_items().removeAt(selectedItem.get_index());
        panelBar.commitChanges();
    };
            When i try to build project i have error window with this description:    
            "Microsoft JScript runtime error: 'this._element' -  is null or not an object".
            
            Please, help me to solve this problem.
            Thank you.
  5. aspUser
    aspUser avatar
    5 posts
    Member since:
    Jun 2011

    Posted 06 Jul 2011 Link to this post

    Hi!
    Does anybody have any ideas about the topic?
  6. Nikolay Tsenkov
    Admin
    Nikolay Tsenkov avatar
    734 posts

    Posted 06 Jul 2011 Link to this post

    Hi Aspuser,

    You shouldn't remove the item from it's previous place. It should be automatically moved.
    Also the error you get, probably happens in run-time, since the JavaScript is not really syntactically checked server-side.


    Regards,
    Nikolay Tsenkov
    the Telerik team

    Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

  7. Ryan
    Ryan avatar
    14 posts
    Member since:
    Sep 2007

    Posted 14 Jul 2011 Link to this post

    Hello,
    I'm trying to do the same thing from the server side.  I want the user to be able to define the order of the panel bar items.  My panel bar items are declared/built on the .aspx page, but I need to reorder them from the code-behind (I'm assuming this would happen in Page_Init).  Is this possible?

    Thanks,
    Ryan
  8. Ryan
    Ryan avatar
    14 posts
    Member since:
    Sep 2007

    Posted 14 Jul 2011 Link to this post

    I'd like to add that I only want to set the order of the items when the page is loaded.  I'm not trying to do this with AJAX or on a postback.  The order of the items is defined on a separate page.
  9. Nikolay Tsenkov
    Admin
    Nikolay Tsenkov avatar
    734 posts

    Posted 19 Jul 2011 Link to this post

    Hello Ryan,

    It most definitely is possible.
    Could you, please, share what exactly seems to be the problem achieving it?
    You probably handle the ItemClick server event?


    Regards,
    Nikolay Tsenkov
    the Telerik team

    Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

  10. Ryan
    Ryan avatar
    14 posts
    Member since:
    Sep 2007

    Posted 19 Jul 2011 Link to this post

    I was wanting to order them on initial page load, not after any event.  Let's say you built the items in this order on the .aspx page:

    Item 1
    Item 2
    Item 3

    Let's say you defined your preferred order (on another page completely separate from this) as

    Item 3
    Item 2
    Item 1

    I wanted to be able to order the items in the code behind (on initial page load) to reflect the preferred order, even though they are declared in a different order on the .aspx page.  Unfortunately, you can't simply change the index of the items to move them around, you get errors.  I've solved my issue by building the items in the code behind in the proper order instead of declaring them on the .aspx page.
  11. Nikolay Tsenkov
    Admin
    Nikolay Tsenkov avatar
    734 posts

    Posted 22 Jul 2011 Link to this post

    Hi Ryan,

    If we assume you have a list with the texts of the items (or if not unique - the values), you can foreach the list and find the item using the appropriate "FindBy..."-method and insert it (itemsCollection.Insert) in the correct position in the collection.

    Regards,
    Nikolay Tsenkov
    the Telerik team

    Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

Back to Top
UI for ASP.NET Ajax is Ready for VS 2017