Gridx

时间:2018-02-05 06:03:26

标签: javascript dojo

我正在使用gridx并尝试在网格的Header区域添加一个复选框,其中将执行某些操作。该复选框不应位于所有标题列上(它必须位于特定列)

我尝试使用headerRegions。

    var hr = grid.headerRegions;
    hr.add(function(col){
        return domConstruct.create('div', {
            id: 'columnHeaderDiv',
            style: 'height: 13px; width: 30px; display: inline-block'
        });
    }, 1, 0);
    hr.refresh();

    var row = domConstruct.toDom("<input id='mycheck' name='mycheck' data-dojo-type='dijit/form/CheckBox' value='agreed' checked onChange=\"alert('onChange called with parameter = ' + arguments[0] + ', and widget value = ' + this.get('value'))\" />");
    domConstruct.place(row, "columnHeaderDiv");
    grid.startup();

我得到的输出是: Header Column

但是,我需要“Column2”,“Column3”,“Column4”上的复选框,而不是“Column1”上的复选框

我浏览了How to add widget to Dojo gridx/Grid header?链接 在上面的链接中有一行说“只影响一个列标题,在回调提供的参数(列)上使用谓词,这是add的第一个参数(最简单的方法是使用列id )”。我不明白这一行。任何人都可以帮助我。

1 个答案:

答案 0 :(得分:0)

hr.add(function(col){
//here the col will have index like 0,1,2 etc... and also id. You can do a check here like or you can do it on ID as well
if(col.index!==1){
return domConstruct.create('div', {
            id: 'columnHeaderDiv',
            style: 'height: 13px; width: 30px; display: inline-block'
        });
}

    }, 1, 0);
    hr.refresh();