【问题标题】:Reloading telerik grid asp.net mvc重新加载telerik网格asp.net mvc
【发布时间】:2015-09-29 16:35:30
【问题描述】:

我的 asp.net mvc 项目中有以下网格

<div class="actualGrid" id="actualGrid">
    @(Html.Kendo().Grid<AVNO_KPMG.Models.Bench>()    //Bench Grid
        .Name("grid")

    .Columns(columns =>
    {
        columns.Bound(p => p.name).Title("Bench").Filterable(ftb => ftb.Cell(cell => cell.Operator("contains"))).Width(150);
        columns.Bound(p => p.freeSeats).Title("Free Seats").Width(250).Filterable(ftb => ftb.Cell(cell => cell.Operator("gte")))
            .ClientTemplate("<div class='barthingy'><div class='bars_text'><div class='seatsText'><img src=\"/images/booked_full_15x15.png\" /> <b>#=bookedSeats#</b> USED SEATS</div><div class='seatsText'><img src=\"/images/booked_15x15.png\" /> <b>#=freeSeats#</b> TOTAL OFSEATS</div></div><div id='bigbar'><div  class='bigbar'  style='width:100%; float:left; background-color:rgb(142, 188, 0);'><div  ' style='float:right; width:#=bookedSeats *100 / seatsCount#%; background-color:rgb(255, 99, 71); height:16px '  class='b_#=name#' id='temp-log'></div></div></div></div>");

        //buttons
        columns.Command(command => { command.Custom("checkBench1 ").Text(" AM ").Click("doCheckIn"); command.Custom("checkBench 2").Text(" PM ").Click("doCheckIn"); command.Custom("checkBench3").Text("All Day").Click("doCheckIn"); }).HtmlAttributes(new { @class = "comms" }).Title("Check in");

    })

    .Pageable()
    .Sortable()

    .Scrollable(scrolling => scrolling.Enabled(false))
            .Filterable(ftb => ftb.Mode(GridFilterMode.Row))
            //.HtmlAttributes(new { style = "height:530px;" })
            .Events(events => events.DataBound("onDataBound"))
    .DataSource(dataSource => dataSource
    .Ajax()
    .PageSize(10)
    .Events(events => events.Error("error_handler"))
    .Model(model => model.Id(p => p.id))
                    .Read(read => read.Action("GetBenches", "Home"))
            )
    )
</div>

我在页面上做了一些事情后,我希望网格刷新 我试过了

var grid = $("#grid").data("kendoGrid");
                grid.dataSource.fetch();

var grid = $("#grid").data("kendoGrid");
                grid.dataSource.read();

但没有运气。还有其他方法可以刷新此网格吗?

【问题讨论】:

  • 有时读取操作可能会被缓存,因为自上次调用以来参数没有更改。确保您在读取操作中遇到断点。如果不是,您可以使用[OutputCache(Duration=0)] 属性在您的控制器中执行您的操作

标签: javascript c# asp.net asp.net-mvc telerik


【解决方案1】:

您还需要刷新 UI:

var grid = $("#grid").data("kendoGrid");
grid.dataSource.read();
grid.refresh();

http://docs.telerik.com/kendo-ui/api/javascript/ui/grid#methods-refresh

【讨论】:

猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-01-19
  • 1970-01-01
  • 2016-04-04
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多