I've looked everywhere for this but can't seem to find exactly what I'm looking for. I'm trying to render a content part shape from an MVC controller using AJAX, but I'm having trouble rendering the shape, which I hope somebody can help with.
I've tried using the 'BuildDisplay' method on the content manager by passing it the content part, but it creates the shape for the item that was returned from my Content Manager query. I've also tried using 'BuildDisplayShape', passing in ContainerPart as T and the item returned from the Content Manager query.
Using Ajax, I'm passing custom id number to my controller. In the controller action, I'm using the Content Manager to query for and return the first item that matches. The item that is returned will always have a container part. I want to take the found item's container part and build the shape that renders the contained items and then return it back to my view where it will be displayed.
[HttpGet]
public ActionResult ReturnChildren(int id)
{
var parent = _contentManager.Query<ItemPart, ItemPartRecord>().Where(o => o.ItemId == id).List().FirstOrDefault();
ContainerPart container = null;
if (parent != null)
{
container = parent.As<ContainerPart>();
}
if (container == null)
{
return null;
}
var shape = _contentManager.BuildDisplay(container, "Summary");
// shape = _contentManager.BuildDisplayShape<ContainerPart>(container.Id, "Summary");
// shape = _contentManager.BuildDisplay(container, "Summary");
//return View("ItemSelector/ReturnChildren", shape);
return new ShapeResult(this, shape);
}
Cheers in advance for the help!