One of the important aspects of NamedLists is that the order of ListsItems can be explicitly set. Lists module API offers two methods for
reodering list items inside of a NamedList:
- MoveItemUp(Guid id) - Item can be moved up in the NamedList by passing the ID of the list item to be moved to the
MoveItemUp method
- MoveItemDown(Guid id) - Alternatively, items can be moved down in the NamedList by passing the ID of the list item to be moved to the
MoveItemDown method
Moving items up in the order of list items inside of a NamedList:
| MoveItemUp(Guid id) |
Copy Code |
|
// create a new instance of ListManager Telerik.Lists.ListManager listManager = new Telerik.Lists.ListManager(); // we are going to move the second item from the first
list to the first place in the list IList allLists = listManager.GetLists(); if
(allLists.Count > 0)
{
// get reference to the first list
Telerik.Lists.INamedList firstList = (Telerik.Lists.INamedList)allLists[0];
if (firstList.Items.Count > 2)
{
// get reference to the second list item of the first list
Telerik.Lists.IListItem secondItem =
(Telerik.Lists.IListItem)firstList.Items[1];
// move the second item one place up and effectively make it first item in the
list
listManager.MoveItemUp(secondItem.ID);
}
}
|
Moving items down in the order of list items inside of a NamedList:
| MoveItemDown(Guid id) |
Copy Code |
|
// create a new instance of ListManager Telerik.Lists.ListManager listManager = new Telerik.Lists.ListManager(); // we are going to move the second item from the first
list to the first place in the list IList allLists = listManager.GetLists(); if
(allLists.Count > 0)
{
// get reference to the first list
Telerik.Lists.INamedList firstList = (Telerik.Lists.INamedList)allLists[0];
if (firstList.Items.Count > 2)
{
// get reference to the second list item of the first list
Telerik.Lists.IListItem secondItem =
(Telerik.Lists.IListItem)firstList.Items[1];
// move the second item one place down and effectively make it third item in the
list
listManager.MoveItemDown(secondItem.ID);
}
}
|
See Also