当网格中的一行展开时,我正在尝试加载局部视图。我的听众是这样的:
x.RowExpander()
.Listeners(ls =>
{
ls.Expand.Handler = string.Format("Item.onListRowExpand('{0}', {1}, this);",
Url.Action("ItemDetail", "My"), Model);
})
onListRowExpand: function(url, listId, expander) {
var container = App.DashboardPanel;
var itemId = expander.componentsCache[0].cmp.record.data.Id;
var panelId = "Details_" + listId + "_" + itemId;
// Check if the selected panel was selected again. If it was do nothing
var panel = container.getComponent(panelId);
if (!panel) {
// Remove the opened panel so we can add a new one
if (container.items.getCount() > 1) {
container.remove(container.items.getAt(1).id);
}
// Add the new panel...
container.add({
id: panelId,
closeable: true,
loader: {
xtype: "panel",
url: url,
renderer: "frame",
params: {
"listId": listId,
"itemId": itemId }
}
});
container.update();
}
}
然后,此方法调用控制器:
public Ext.Net.MVC.PartialViewResult ItemDetail(int listId, int itemId)
{
var result = new Ext.Net.MVC.PartialViewResult
{
RenderMode = RenderMode.AddTo,
ContainerId = "MyPanel",
WrapByScriptTag = false,
Model = new ItemViewModel
{
ListId = listId,
ItemId = itemId
}
};
return result;
}
它应该返回要添加到容器的
Items
@(x.Container()
.ID("MyPanel")
.Layout(LayoutType.HBox)
.Loader(x.ComponentLoader()
.Url(Url.Action("ViewList", "My"))
.Mode(LoadMode.Script)
.Params(new { listId = Model.ListId })))
视图如下所示:
@model ItemViewModel
@{
var x = Html.X();
}
@(x.Panel()
.LayoutConfig(new HBoxLayoutConfig {Align = HBoxAlign.StretchMax})
.Flex(1)
.Items(
x.Button().Text("Temp").Flex(1)))
WrapByScriptTag
为true—在这种情况下,我会得到一个错误,声明“uncaughtreferenceerror:Ext is not defined”),或者如果设置
WrapByScript标签
错误的。我知道我错过了一个地方的设置,但我不知道是什么错。任何帮助都将不胜感激。