Lists & List Items

Posted by Community Admin on 05-Aug-2018 14:40

Lists & List Items

All Replies

Posted by Community Admin on 28-May-2011 00:00

The List Item manager could really use to option to move from one list to another.

-- 
Stuart

Posted by Community Admin on 31-May-2011 00:00

Hello Stuart,

Excuse me for the question, do you mean that List items should be moved from one list to another?

Greetings,
Stanislav Velikov
the Telerik team

Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

Posted by Community Admin on 31-May-2011 00:00

Hi Stanislav,

Yes, that's what I'm talking about.

-- 
Stuart

Posted by Community Admin on 02-Jun-2011 00:00

Hi Stuart,

We appreciate your suggestion and I have logged it as a feature request. The team will discuss it and take actions.

Best wishes,
Stanislav Velikov
the Telerik team

Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

Posted by Community Admin on 16-Apr-2012 00:00

Hi,

Meanwhile, is there a way to do it through the API? If so, how?
I tried this, but it doesn't work (the parent is null in the DB):

var lm = ListsManager.GetManager();
 
// Get list item
 
var listItemTemp = lm.Lifecycle.CheckOut(listItem) as ListItem;
var parentId = App.WorkWith().Lists().Where(l => l.Title == listName).Get().Single().Id;
listItemTemp.Parent = lm.GetList(parentId);
 
var listItemMaster = lm.Lifecycle.CheckIn(listItemTemp) as ListItem;
lm.Lifecycle.CheckIn(listItemTemp);
lm.Lifecycle.PublishWithSpecificDate(listItemMaster, listItem.PublicationDate, Thread.CurrentThread.CurrentCulture);
 
lm.SaveChanges();

I also tried doing oldList.ListItems.Remove(item) then newList.ListItems.Add(item), but this doesn't work either. It removes the item from the old list, but doesn't add it to the new list. Same thing if you call Add without calling Remove first.

Thanks.

Posted by Community Admin on 19-Apr-2012 00:00

Hi again,

I still couldn't find a solution. I thought of another way to do it: create new list items from scratch, and manually copy all their properties. This works, except for taxonomy associations, which I can't manage to copy.

var listItemClone = lm.CreateListItem();
listItemClone.Title = listItem.Title;
listItemClone.Content = listItem.Content;
listItemClone.Owner = listItem.Owner;
listItemClone.LastModifiedBy = listItem.LastModifiedBy;
listItemClone.SetValue("Category", listItem.GetValue("Category")); // does not work

Can anyone help? Thanks.

Edit: I found out this works to set the taxa of a list item:
listItemClone.Organizer.AddTaxa("Category", listItem.GetValue<TrackedList<Guid>>("Category").ToArray());

Posted by Community Admin on 26-Apr-2012 00:00

That's a great setting moving list to another. I've heard that before but never been try.

This thread is closed