Skip Navigation LinksHome / Community & Support / Code Library / ASP.NET AJAX > General and Integration Projects > Sorting, filtering, or applying any custom rule to an item collection of RadMenu, Radpanelbar, RadTabstrip, RadTreeview or RadCombobox

Sorting, filtering, or applying any custom rule to an item collection of RadMenu, Radpanelbar, RadTabstrip, RadTreeview or RadCombobox

Feed from this thread
  • Posted on Jun 18, 2007 (permalink)

    Requirements

    RadControls version

    Q1 2007

    .NET version

    2.0    

    Visual Studio version

    2005

    programming language

    C#, VB

    browser support

    all browsers supported by RadControls


     
    PROJECT DESCRIPTION
    This project shows how to sort the child items of data-bound RadMenu, RadPanelbar, RadTabstrip and RadTreeview in the DataBound event. The items of a RadCombobox are sorted on button click. 

    The key idea in this approach is that I store the child items in a collection of the respective type (RadMenuItemCollection, RadPanelItemCollection...). Then I clear the parent item(owner) of its child items collection and add the items again based on some rule. In this project I sort the items by text, but you can easily adjust the approach to sort them by any other property including custom attributes or you can filter the items or just apply any custom rule.
     
    This is a really flexible method which can suit almost any scenario related to reorganizing a collection of items. The controls do not have to be data-bound but in this case you will have to use the Page Load event. Detailed comments are inserted in the code. I hope you find this project useful and easy to use.
    Attached files

    Reply

  • AnanthR avatar

    Posted on Jun 21, 2007 (permalink)

    Would'nt it be better to just sort in a PreRender ? Currently the logic would sort for every item (every tab in the tabstrip for example) that is databound?

    Reply

  • Peter Peter admin's avatar

    Posted on Jun 22, 2007 (permalink)

    Hi Ananth,

    That's a great question! I am glad you raised it. PreRender event will work just fine because it occurs after the DataBound event. However, if you test the approach with Page Load you will find out that it will not sort the items, because Page Load happens before DataBound.

    If the menu is declared inline in the aspx page, the Page Load event is can be used as well as PreRender.


    Kind regards,
    Peter
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center

    Reply

  • Posted on Sep 4, 2007 (permalink)

    The only way I could get it to work for a tree view was in the PreRender event, the DataBound event would not do the sort

    It slows things down quite a bit, but it works

    Reply

  • Posted on Sep 5, 2007 (permalink)

    I was wrong - once implemented, all the functionality of the tree view stopped working. The nodechecked event no longer worked correctly and many of the other items stopped working.

    I decided to use a DataVew instead of a DataSet as the source. The DataView is sortable. Works great

    Reply

Back to Top

Skip Navigation LinksHome / Community & Support / Code Library / ASP.NET AJAX > General and Integration Projects > Sorting, filtering, or applying any custom rule to an item collection of RadMenu, Radpanelbar, RadTabstrip, RadTreeview or RadCombobox