【发布时间】:2019-12-13 05:55:09
【问题描述】:
Bootstrap Modal 弹出窗口中的 ViewComponent
我正在尝试将 ViewComponent 呈现为引导模式的模式数据。 我的 ViewComponent 由 Telerik Kendo UI Grid 组成,因为该网格在许多地方都被使用,我将其作为 Viewcomponent 但无法将其呈现为模态内容。
ViewComponent 类文件:
public class PriorityListViewComponent: ViewComponent
{
public IViewComponentResult InvokeAsync()
{
var items = GetToDoItems();
return View("Default", items);
}
}
ViewComponent 查看文件(路径:Views/Home/Components/PriorityList/Default.cshtml)
@model IEnumerable<GettingStartedWithTelerik.Models.Customer>
@(Html.Kendo().Grid(Model)
.Name("grid1234")
.Columns(columns =>
{
columns.Bound(c => c.ContactName).Width(140);
columns.Bound(c => c.ContactTitle).Width(190);
columns.Bound(c => c.CompanyName);
columns.Bound(c => c.Country).Width(110);
})
.HtmlAttributes(new { style = "height: 380px;" })
.Scrollable()
.Sortable()
.Pageable(pageable => pageable
.Refresh(true)
.PageSizes(true)
.ButtonCount(5))
.DataSource(dataSource => dataSource
.Ajax()
.ServerOperation(false)
))
我可以从任何视图中渲染 ViewComponent,如下所示
@await Component.InvokeAsync("PriorityList")
在引导模式内容中使用上述行时,它会在页面加载本身期间加载网格,但在我手动单击按钮触发引导模式时不会加载。
【问题讨论】:
标签: c# asp.net-core kendo-grid bootstrap-modal asp.net-core-viewcomponent