【问题标题】:Telerik MVC grid-How to Change "no record message" between ajax calsTelerik MVC 网格-如何更改 ajax cals 之间的“无记录消息”
【发布时间】:2011-02-04 11:25:12
【问题描述】:

我正在使用 Telerik MVC 网格 ajax 绑定来显示一些记录。 加载网格时,网格中的消息是“未找到记录”。 当 ajax cal 完成后,消息就会消失并加载数据。 但是,在加载数据之前,“未找到记录”的消息会让用户感到困惑。

谁能告诉我如何在 ajax cal 完成之前将此消息更改为“正在加载...”。

谢谢。

【问题讨论】:

    标签: telerik-mvc


    【解决方案1】:

    在您的网格中搜索t-no-data 类。类似的东西

    $('#ReportGrid').find('.t-no-data td').text('Loading...');
    

    应该进入你的网格的onLoad()

    【讨论】:

      【解决方案2】:

      IMO,将“.NoRecordsTemplate("Loading...")”添加到网格是更好的方法。

                  @(Html.Telerik().Grid<RatingListItem>()
                  .Name("Rating_Index_List")
                  .Columns(columns =>
                  {
                      columns.Bound(o => o.Id).Hidden();
                      columns.Bound(o => o.Score)
                  })
                  .DataBinding(dataBinding => dataBinding.Ajax().Select(Model.ListPageGridModel.DataRequestAction.ActionName, Model.ListPageGridModel.DataRequestAction.ControllerName))
                  .Pageable(settings => settings.Total(Model.ListPageGridModel.TotalRow))
                  .EnableCustomBinding(true)
                  .Sortable()
                  .NoRecordsTemplate("Loading...")
                  )
      

      【讨论】:

      • -1 - 如果您使用 NoRecordsTemplate,如果没有要显示的记录,用户将看到“正在加载...”消息。
      【解决方案3】:

      我建议使用以下方法,而不是使用 NoRecordsTemplate:

      1. 将客户端事件添加到您的网格:.ClientEvents(events => events.OnLoad("Grid_onLoad"))
      2. 添加一个javascript函数: 函数 Grid_onLoad(e) { $('.t-no-data td').text('正在加载'); }

      这样,如果没有记录,网格仍然会显示“No Records Found”,但用户会在 ajax 调用期间看到“Loading”消息。

      【讨论】:

        【解决方案4】:

        您可以使用 .NoRecordsTemplate 来设置加载时间,并通过 OnDataBound 事件来指定什么时候没有记录。

          @Html.Telerik().Grid<ViewModel>().Name("Temp")
          .NoRecordsTemplate("Loading ... Please Wait")
          .ClientEvents(e => e.OnDataBound("onDataBound"))
        

        脚本代码

        function onDataBound() {
            $("tr.t-no-data td").html("No records to display");
        }
        

        【讨论】:

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