【问题标题】:How to add empty rows to the ExtJS Grid?如何将空行添加到 ExtJS 网格?
【发布时间】:2011-08-17 20:55:47
【问题描述】:

我有带有分页的网格。每页最多有 10 行。像这样:

我在 CSS 中为 .x-grid3-scroller 选择器设置了渐变背景。一切都很好,而 DirectStore 中有 10 个项目。但是,如果项目少于 10,我会遇到这个问题:

如果为 .x-grid3-scroller 设置条纹背景,则列中将没有边框。

如何在网格中添加空行以使网格适合底部?

【问题讨论】:

    标签: javascript extjs grid rows


    【解决方案1】:

    加载存储后(使用load监听器)检查有多少记录(getCount()方法)并添加(add()方法)10 - store.getCount()空记录。

    store.on('load', function(store) {
      var records = new Array();
      for(var i = 10 - store.getCount(); i > 0; i--) {
         records.push(new store.recordType(/*you might need to provide default data here*/))
      }
      store.add(records);
    });
    

    【讨论】:

    • 谢谢!我不知道为什么,但我想如果我将一个空记录添加到存储中,这会破坏寻呼机。但一切都很好。再次感谢您!
    猜你喜欢
    • 2011-11-14
    • 1970-01-01
    • 2013-07-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-08-10
    • 1970-01-01
    • 2017-08-23
    相关资源
    最近更新 更多