+1-888-365-2779
Try Now
More in this section

Forums / Sitefinity SDK / Reorder categories

Reorder categories

19 posts, 0 answered
  1. Duneel
    Duneel avatar
    166 posts
    Registered:
    08 Dec 2010
    22 Jun 2011
    Link to this post
    Hi,

    Is there a way to change the order of the categories? My customer wants to specify the order for the categories he creates.

    Thanks,
    Duneel
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    22 Jun 2011
    Link to this post
    Hi Duneel,

    The default filter is  Ordinal

    You can modify the sort expression of service by mapping Telerik.Sitefinity.Taxonomies.Web.UI.Hierarchical.HierarchicalTaxonList and setting DefaultSortExpression of ItemsTreeTable control to a property of Taxon.

    You can map the type from Sitefinity/Administration/Settings/Advanced >> Controls >> ViewMap. I can attach the template of the built-in control if the above will solve your issues.

    Greetings,
    Ivan Dimitrov
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>

  3. Duneel
    Duneel avatar
    166 posts
    Registered:
    08 Dec 2010
    22 Jun 2011
    Link to this post
    Hi Ivan,

    Thanks for the quick reply.

    Currenty in my webapp the categories are retrieved and listed in a custom widget. They'll appear in the same order that they returned from Sitefinity. So I want to know where there is a way to re-arrange categories from sitefinity backend like we do for pages (drag-drop to change the order).

    Thanks!
    Duneel
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    22 Jun 2011
    Link to this post
    Hello Duneel,

    Since you have a custom  widget why don't you change the list order which will result in the control output?

    Kind regards,
    Ivan Dimitrov
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>

  5. Duneel
    Duneel avatar
    166 posts
    Registered:
    08 Dec 2010
    05 Jul 2011
    Link to this post
    Hi Ivan,

    What did you mean by "change the list order"? The logic I have implemented in my custom widget is very simple. That is to read the list of categories and show them in the same order the categories are retrieved. Now the customer wants to re-order the categories as they want. How should I give them such feature? Is this something that I will have to custom implement on the widget itself?

    Thanks,
    Duneel
  6. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    05 Jul 2011
    Link to this post
    Hello Duneel,

    One of the simplest way to reorder a list of items is using OrderBy. If you need more complex ordering you can create a helper method that returns a list of your objects in the way you want them. In this method you need to get and return the lements of a sequence.

    Greetings,
    Ivan Dimitrov
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>

  7. Duneel
    Duneel avatar
    166 posts
    Registered:
    08 Dec 2010
    05 Jul 2011
    Link to this post
    Hi Ivan,

    Thanks for the quick response. The order for the items that the customer wants is not always assecending or descending so the order by desnt work. They are looking for something so they can order the items any way they wants. (Good example is the pages backend view, where the admin can drag-drop the pages to re-order).

    Thanks,
    Duneel
  8. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    05 Jul 2011
    Link to this post
    Hi Duneel,

    You can use RadTreeView which supports Drag and Drop

    http://demos.telerik.com/aspnet-ajax/treeview/examples/functionality/draganddropnodes/defaultcs.aspx

    Regards,
    Ivan Dimitrov
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>

  9. Duneel
    Duneel avatar
    166 posts
    Registered:
    08 Dec 2010
    05 Jul 2011
    Link to this post
    Hi Ivan,

    In Categories back-end list page, there is an action menu for Move Up & Move Down. What doest it do? Can I use that feature to reorder the items? Currently if click either one of them causes and error saying "Cannot move the first taxon up". See the attached error message.

    Thanks,
    Duneel
  10. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    06 Jul 2011
    Link to this post
    Hello Duneel,

    You get "Cannot move first taxon up" if you click on the first item in the list. Since this is the item in the first position, there is no element above it, so you cannot move the item one level up.

    In the backend we use ItemsTreeTable control.

    <sfLists:ItemsTreeTable id="hierarchicalTaxa" runat="server"
          ServiceBaseUrl="~/Sitefinity/Services/Taxonomies/HierarchicalTaxon.svc/"
          ServiceChildItemsBaseUrl="~/Sitefinity/Services/Taxonomies/HierarchicalTaxon.svc/subtaxa/"
          ServicePredecessorBaseUrl="~/Sitefinity/Services/Taxonomies/HierarchicalTaxon.svc/predecessor/"
          OnClientItemCommand="itemsGrid_ItemCommand"
          OnClientCommand="itemsGrid_Command"
          BindOnSuccess="true"
          ParentDataKeyName="ParentTaxonId"
          DataKeyNames="Id"
          DefaultSortExpression="Ordinal"
          DeleteMultipleConfirmationMessage="<%$Resources:Labels, ItemsAreAboutToBeDeleted %>"
          DeleteSingleConfirmationMessage="<%$Resources:Labels, AreYouSureYouWantToDeleteItem %>"
          LoadingPanelID="hierarchicalTaxaLoadingPanel"
          AllowMultipleSelection="true">
          <ToolboxItems>
              <sitefinity:CommandToolboxItem runat="server" ContainerId="toolbar" CommandName="create" CommandType="CreateButton" WrapperTagName="li" WrapperTagCssClass="sfMainAction" />
              <sitefinity:CommandToolboxItem runat="server" ContainerId="toolbar" CommandName="groupDelete" Text='<%$Resources:Labels, Delete %>' WrapperTagName="li" />
              <sitefinity:MenuToolboxItem runat="server" ContainerId="toolbar" Text='<%$Resources:Labels, Move %>' WrapperTagName="li" WrapperTagCssClass="moveMenu">
                  <CommandItems>
                      <sitefinity:MenuCommandItem runat="server" Text='<%$Resources:Labels, Up %>' CommandName="batchMoveUp" />
                      <sitefinity:MenuCommandItem runat="server" Text='<%$Resources:Labels, Down %>' CommandName="batchMoveDown" />
                      <sitefinity:MenuCommandItem runat="server" Text='<%$Resources:TaxonomyResources, ChangeParent %>' CommandName="batchChangeParent" />
                  </CommandItems>
              </sitefinity:MenuToolboxItem>
          </ToolboxItems>
          <Dialogs>
              <sitefinity:DialogDefinition
                  OpenOnCommandName="create"
                  Name="HierarchicalTaxonForm"
                  CssClass="sfMaximizedWindow" />
              <sitefinity:DialogDefinition
                  OpenOnCommandName="edit"
                  Name="HierarchicalTaxonForm"
                  CssClass="sfMaximizedWindow"
                  Parameters="?TaxonId={{Id}}" />
              <sitefinity:DialogDefinition
                  OpenOnCommandName="editTaxonomy"
                  Name="TaxonomyForm"
                  CssClass="sfMaximizedWindow" />
              <sitefinity:DialogDefinition
                  OpenOnCommandName="changeParent"
                  IsModal="true"
                  Name="ChangeParentDialog"
                  InitialBehaviors="Close"
                  Behaviors="Close"
                  Skin="Sitefinity"
                  VisibleTitlebar="true"
                  Width="425"
                  Height="400" />
              <sitefinity:DialogDefinition OpenOnCommandName="permissionsForAllItems" Name="ModulePermissionsDialog" CssClass="sfMaximizedWindow" />
          </Dialogs>
          <Links>
              <sitefinity:LinkDefinition CommandName="viewItems" />
          </Links>
          <Items>
              <sfLists:ItemDescription Name="Title" HeaderText="<%$Resources:Labels, Title %>" IsSearchField="false" DisableSorting="true" HeaderCssClass="sfTitleCol" ItemCssClass="sfTitleCol">
                  <div>
                      <a href="#" class="sf_binderCommand_edit sfItemTitle"><strong>{{Title}}</strong></a>
                  </div>
              </sfLists:ItemDescription>
              <sfLists:ItemDescription HeaderText="<%$ Resources:LocalizationResources, Translations %>" Name="Translations" IsSearchField="false" ItemCssClass="sfLanguagesCol" HeaderCssClass = "sfLanguagesCol"/>
              <sfLists:ItemDescription Name="Title" HeaderText="<%$Resources:Labels, Actions %>" IsSearchField="false" DisableSorting="true" Width="80">
                  <ul id="actions" class="actionsMenu">
                      <li>
                          <a menu="actions" href="javascript:viod(0);">{$Labels,Actions$}</a>       
                          <ul>
                              <li>
                                  <a sys:href="#" class="sf_binderCommand_delete sfDeleteItm">{$Labels, Delete$}</a>
                              </li>
                              <%--<li class="sfSeparator">
                                  <strong>{$Labels,CreateA$}...</strong>
                              </li>--%>
                              <li class="sfSeparator">
                                  <a sys:href="#" class="sf_binderCommand_createChild sfCreateChild">{$TaxonomyResources,ChildCategory$}</a>
                              </li>
                              <%--<li>
                                  <a sys:href="#" class="sf_binderCommand_createSiblingBefore"">{$TaxonomyResources,SiblingCategoryBefore$}</a>
                              </li>
                              <li>
                                  <a sys:href="#" class="sf_binderCommand_createSiblingAfter">{$TaxonomyResources,SiblingCategoryAfter$}</a>
                              </li>--%>
                              <li class="sfSeparator">
                                  <strong>{$Labels,Move$}...</strong>
                              </li>
                              <li>
                                  <a sys:href="#" class="sf_binderCommand_moveUp sfMoveUp">{$Labels,Up$}</a>
                              </li>
                              <li>
                                  <a sys:href="#" class="sf_binderCommand_moveDown sfMoveDown">{$Labels,Down$}</a>
                              </li>
                              <li>
                                  <a sys:href="#" class="sf_binderCommand_changeParent">{$TaxonomyResources,ChangeParent$}</a>
                              </li>
                              <li class="sfSeparator">
                                  <strong>{$Labels,Edit$}...</strong>
                              </li>
                              <li>
                                  <a sys:href="#" class="sf_binderCommand_edit">{$Labels,Properties$}</a>
                              </li>
                          </ul>
                      </li>
                  </ul>
              </sfLists:ItemDescription>
              <sfLists:ItemDescription Name="UrlName" HeaderText="<%$Resources:Labels, Url %>" IsSearchField="false" DisableSorting="true" Width="150" HeaderCssClass="sfUrl" ItemCssClass="sfUrl">
                  <div>{{UrlName}} </div>
              </sfLists:ItemDescription>
              <sfLists:ItemDescription Name="AppliedTo" HeaderText="<%$Resources:Labels, AppliedTo %>" IsSearchField="false" DisableSorting="true" Width="100" HeaderCssClass="sfNumeric" ItemCssClass="sfNumeric">
                  <div>
                      <a class="sf_binderCommand_viewItems" href="#">{{ItemsCount}} {$Labels, Items$}</a>
                  </div>
              </sfLists:ItemDescription>
          </Items>
      </sfLists:ItemsTreeTable>

    and when you perform an operation like move up /move down we call ClientManager that invokes the service to commit the transaction

    clientManager.InvokePut(baseUrl, urlParams, keys, data, moveTaxons_Success, moveTaxons_Failure);

    Regards,
    Ivan Dimitrov
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>

  11. Duneel
    Duneel avatar
    166 posts
    Registered:
    08 Dec 2010
    06 Jul 2011
    Link to this post
    Hi Ivan, Even if I select an item in the middle and try to move, I still get the same error. I believe it is a bug in Sitefinity. Can you please confirm? Thanks, Duneel
  12. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    06 Jul 2011
    Link to this post
    Hi Duneel,

    I cannot replicate this issue with the latest official version. If you are using it, please provide some detailed steps that we can follow to try to replicate this issue and confirm whether it is a bug  or not.

    Regards,
    Ivan Dimitrov
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>

  13. Duneel
    Duneel avatar
    166 posts
    Registered:
    08 Dec 2010
    06 Jul 2011
    Link to this post
    Here are the steps to reproduce the issue.

    Create a Category
    And create few other categories within the first category.
    Now try to move the dhild categories up and down.

    Thanks,
    Duneel
  14. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    06 Jul 2011
    Link to this post
    Hello Duneel,

    I am not able to replicate this issue with the latest official release.

    All the best,
    Ivan Dimitrov
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>

  15. Duneel
    Duneel avatar
    166 posts
    Registered:
    08 Dec 2010
    06 Jul 2011
    Link to this post
    Hi Ivan,

    Ours is not a fresh site built on the latest SF 4 build. It was originally 4.0 and then updated everytime a new build was out and now it's the latest build. Could that be the problem? How should we go about this?

    We are using version 4.1.1501. I tried the same on a fresh website created on the latest build and it's working fine there. So I suspect that something is wrong when the site was originally built in 4.0 and then updated to the latest version.

    Thanks,
    Duneel
  16. GeorgePPetrov
    GeorgePPetrov avatar
    18 posts
    Registered:
    24 Sep 2012
    11 Jul 2011
    Link to this post
    Hi Duneel,

    I will be glad to assist in solving your problem. Is it possible for you to send us your copy of your website and database so I can restore it locally and reproduce and debug the issue. Since there are many upgrades of the site I am not sure that my attempt to follow what you did will give the same result.

    Greetings,
    GeorgePPetrov
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>

  17. Madhavan
    Madhavan avatar
    19 posts
    Registered:
    31 Jan 2011
    13 Jul 2011
    Link to this post
    Hi,

      How do I sort the categories in the blogs, News section to be by name. Currently I donot know in which order it is being displayed.

    Thanks
    Madhavan
  18. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    14 Jul 2011
    Link to this post
    Hello Madhavan,

    The problem is that we do not pass sort expression to the HierarchicalTaxon service and the taxon items are not retrieves in the correct list order. I logged a pits issue about this issue that you can follow

    Public Url: http://www.telerik.com/support/pits.aspx#/public/sitefinity/6952

    Best wishes,
    Ivan Dimitrov
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>

  19. Duneel
    Duneel avatar
    166 posts
    Registered:
    08 Dec 2010
    21 Jul 2011
    Link to this post
    Hi George,

    I was able to figure out wats going on and the issue was now fixed. I looked in the database and for some reason all the categories had the same value ("3") for the ordinal. That may be because the database was initially created for 4.0 and then upgraded. So I manually adjusted the ordinal field to have different values.

    Thanks,
    Duneel
19 posts, 0 answered