【发布时间】:2012-12-06 09:15:45
【问题描述】:
我正在使用 Kendo UI Grid。有没有办法在与第一页不同的页面开始网格? 每次打开网格时,我都想将初始页码设置为“3”。
【问题讨论】:
标签: asp.net-mvc kendo-ui
我正在使用 Kendo UI Grid。有没有办法在与第一页不同的页面开始网格? 每次打开网格时,我都想将初始页码设置为“3”。
【问题讨论】:
标签: asp.net-mvc kendo-ui
我建议您将 Grid 的 AutoBind 属性设置为 false 并在文档就绪事件发生时使用 page 方法dataSource(实际上是 pager.page 调用的内容)。
$('#MyGrid').data().kendoGrid.dataSource.page(3);
您使用的 Data 函数的用途略有不同 :)
【讨论】:
我使用 ajax 数据源,我需要这样做:
这是我的观点的片段(我使用剃须刀): 注意:在操作中,我在 ViewBag 中设置了两个值:
.
@{
int initialPage = (int)ViewBag.InitialPage;
int totalPages = (int)ViewBag.Total / 20;
}
@(Html.Kendo().Grid<YourModelClass>
()
.Name("gridMain")
.Columns(columns =>
{
//Todo: Add your columns
})
.Pageable(p => p.Refresh(true).Info(true).Input(true).ButtonCount(6).Numeric(true))
.Sortable()
.Scrollable()
.Filterable()
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(20)
.Read(read => read.Action("YourAction", "YourController"))
.Total(ViewBag.Total) //Set the total record count
)
.AutoBind(false)
)
<script type="text/javascript">
$(function () {
var initialPage = @initialPage;
$('#gridMain').data().kendoGrid.dataSource.page(initialPage);
})
</script>
【讨论】: