如何将小部件添加到Dojo gridx / Grid标头? [英] How to add widget to Dojo gridx/Grid header?

查看:82
本文介绍了如何将小部件添加到Dojo gridx / Grid标头?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有gridx / Grid( http://oria.github.io/gridx/ )并且我想在标题单元格中添加一些小部件,例如文本框,下拉列表等。是否可以将小部件放在标题单元格中?

I have gridx/Grid (http://oria.github.io/gridx/) and I want to add some widgets in header cells like textboxes, dropdowns etc. Is there a way to put widget in header cell?

推荐答案

似乎您需要的是名为 HeaderRegions 的模块。这是 API
。尤其要注意 add refresh 方法。

It seems that what you need is a module called HeaderRegions. Here is it's API . Especially note the add and refresh methods.

一个简单的示例,请此处

要只影响一个列标题,请在回调提供的参数(列)上使用谓词,该谓词是 add 的第一个参数(最简单的方法是使用列ID)。

To affect only one column header, use a predicate on the argument (column) provided by the callback that is the first argument of add (easiest would be to use the column id).

要插入小部件,请以编程方式创建它,并启动 startup 方法并返回它的 domNode 属性。

To insert a widget, create it programatically, fire it's startup method and return it's domNode attribute.

(我不确定,但是 startup 应该在之后为此,您可能必须在方法之外保留对小部件的引用)

(I am not sure but it may be that startup should be called after the grid is rendered. For this you may have to keep a reference to the widget outside the method)

为完整起见,我包括上面链接的一些示例:

For completeness, I include the some of the example linked above:

Deferred.when(parser.parse(), function() {
  var hr = grid1.headerRegions;
  hr.add(function(col) {
    return domConstruct.create('div', {
      style: 'height: 13px; width: 10px; background-color: red;'
    });
  }, 0, 0);
  hr.add(function(col) {
    return domConstruct.create('div', {
      style: 'height: 13px; width: 10px; background-color: green;'
    });
  }, 1, 0);
  hr.refresh();
});

这篇关于如何将小部件添加到Dojo gridx / Grid标头?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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