javascript - Kendo UI 多个网格的一个数据源

标签 javascript jquery css kendo-ui

我最近遇到 Kendo UI 问题,我有 1 个数据源,它被 3 个网格使用。这一切都有效,但由于某种原因,由于缺乏更好的词,网格的样式被“拆除”。

如果我从网格 A 中过滤数据源,网格 A 看起来不错,但网格 B 和 C 看起来像这样(不要介意列中的名字“Error”):

Grid B and C

如果我从网格 B 过滤数据源,网格 B 现在看起来不错,但网格 A 和 C 看起来“已拆除”。可能是什么问题?

网格 A:

    $('#grid-a').kendoGrid({
      autoBind: false,
      dataSource: emp_ds,
      toolbar: kendo.template($("#mainlist-template").html()),
      scrollable: true,
      sortable: true,
      selectable: 'row',
      pageable: {
        input: true,
      },
      columns: [{
          field: "id",
          title: "ID",
          width: 100
        },{
          field: "firstname",
          title: "Firstname"
        },{
          field: "lastname",
          title: "Lastname"
        }
      ]
    });

网格 B:

    $('#grid-b').kendoGrid({
      autoBind: false,
      dataSource: emp_ds,
      toolbar: kendo.template($("#emplist-template").html()),
      scrollable: true,
      sortable: true,
      selectable: 'row',
      pageable: {
        input: true,
      },
      columns: [{
          field: "id",
          title: "ID",
          width: 100
        },{
          field: "firstname",
          title: "Firstname"
        },{
          field: "lastname",
          title: "Lastname"
        },{ 
          command: {
            text: 'Select',
            click: function(e) {
              e.preventDefault();

              if(employeeSelectSwitch == 2) {
                return;
              }

              varholder.curUid = $(e.currentTarget).closest("tr").data('uid');

              $('#daterange-dialog').data('kendoWindow').center().open();
            }
          },
          width: 140
      }]
    });

数据源:

emp_ds = new kendo.data.DataSource({
    transport: {
      read: {
        dataType: 'json',
        url: url.employeeList
      }
    },
    schema: {
      model: {
        fields: {
          id: { type: 'number' },
          firstname: { type: 'string' },
          lastname: { type: 'string' },
        }
      }
    },
    pageSize: 15
  });

最佳答案

开玩笑为什么你需要 3 个网格来显示相同​​的数据,如果你不共享数据源,请使用 3 个数据源。故事看看@Kendo 共享数据源。

关于javascript - Kendo UI 多个网格的一个数据源,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14042958/

相关文章:

javascript - 重用 XMTHttpRequest 对象?

javascript - 导航/子导航列表,如何在页面重新加载后为点击的项目提供事件类

CSS 空白 :pre always renders a horizontal scrollbar in firefox

javascript - 根据多种条件处理不同颜色的文本

html - contenteditable 中的光标在 Chrome 中无法正常运行

javascript - 如果高度改变滚动 HTML div

javascript - 好的或坏的主意 : load database as a separate . js 文件

用于将 D3 js v3 迁移到 v4 的 Javascript 编译

javascript - 函数不识别 .data() 值 jquery

javascript - 不确定为什么日期和数组之间的比较找不到匹配项