我到处都在寻找这个,但似乎找不到我要找的东西。我正在尝试使用AJAX从MVC控制器渲染内容零件形状,但是我在渲染形状时遇到了麻烦,希望有人可以提供帮助。
我尝试通过向内容管理器传递内容部分来在其上使用'BuildDisplay'方法,但是它为从我的内容管理器查询返回的项目创建了形状。我也尝试过使用“ BuildDisplayShape”,将ContainerPart作为T传递,并将内容管理器查询返回的项目传递给T。
使用Ajax,我正在将自定义ID号传递给控制器。在控制器操作中,我使用内容管理器查询并返回匹配的第一项。返回的项目将始终具有容器部分。我要使用找到的项目的容器部分,并构建呈现所包含项目的形状,然后将其返回到我将在其中显示的视图中。
[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);
}
提前加油帮助!
我结束了添加一个新视图以完全包含我要显示的内容的过程,并创建了自己的详细信息类型,该类型在零件驱动程序中进行处理。由于没有其他部分使用我的自定义详细信息类型,因此我不必隐藏其他任何形状。在控制器中,我能够做到:
var shape = _contentManager.BuildDisplay(container, "myDetailType");
谢谢您对Hazza的帮助。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句