用于MVC网格的Kendo UI如何隐藏ID列 [英] Kendo UI for MVC Grid How do I hide the ID column

查看:143
本文介绍了用于MVC网格的Kendo UI如何隐藏ID列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想隐藏Kendo网格的ID列,但仍然可以引用它进行其他操作.我尝试使Width = 0,但这只能使其真正变宽.

I would like to hide the ID column of a Kendo grid but still be able to reference it for other actions. I tried making the Width = 0 but that only makes it really wide.

@(Html.Kendo().Grid(Model)
        .Name("LineItems")
        .Columns(columns =>
            {
                columns.Bound(o => o.ID).Width(1);
                columns.Bound(o => o.Ui).Width(20);
                columns.Bound(o => o.QtyOrdered).Width(20);
                columns.Bound(o => o.Nomenclature).Width(200);
                columns.Bound(o => o.QtyShipped).Width(140);
                columns.Bound(o => o.QtyReceived).Width(200);
                columns.Bound(o => o.Hazmat).Width(50);

            })

6月26日修改

好的,我可以根据Kendo论坛上的帖子获得合理的解决方案.只要在数据源中定义了ID,就不必在网格中定义该列.您仍然有权访问ID值.我写了一个简短的代码片段来证明这一点,它返回的ID不包含网格中的ID列.

OK I was able to get a reasonable solution based on a post from the Kendo forum. As long as the ID is defined in the datasource, the column does not have to be defined in the grid. You still have access to the ID value. I wrote a quick snippet to prove it and it returns the ID without the ID column in the grid.

<script>
  $(document).ready(function () {
      $("#btn").on("click", function () {

          var grid = $("#LineItems").data("kendoGrid");
          var data = grid.dataSource.data();
          $.each(data, function (i, item) {
              alert(item.ID);
           });
      });
  });
</script>

自2012年第二季度发布以来,支持

推荐答案

隐藏的列.现在,您可以使用Hidden()设置.

Hidden columns are supported since the Q2 2012 release. You can now use the Hidden() setting.

这篇关于用于MVC网格的Kendo UI如何隐藏ID列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆