2

我正在创建如下所示的道场网格,并且我正在使用indirectSelection 插件来创建一个复选框,如下所示,但默认情况下,复选框将位于网格的第一列。我如何让它出现在最后一列?

var grid = new dojox.grid.EnhancedGrid({
        id: 'serialsGrid',
        style: 'width:auto;height:250px;',
        store: store,
        structure: layout,
        rowSelector: '20px',
        plugins: {
            indirectSelection: {name:'Requested',headerSelector:true, width:"40px", styles:"text-align: center;"},
          pagination: {
              pageSizes: ["25", "50", "100", "All"],
              description: true,
              sizeSwitch: true,
              pageStepper: true,
              gotoButton: true,
                      /*page step to be displayed*/
              maxPageStep: 4,
                      /*position of the pagination bar*/
              position: "bottom"
          }
        }
    }, document.createElement('div'));

    /*append the new grid to the div*/
    //var temp=grid.domNode;
    dojo.byId("serialsGridDiv").appendChild(grid.domNode);
    /*Call startup() to render the grid*/
    serialsGridCopy=grid;
    grid.startup();
});
4

1 回答 1

1

据我所知,插件本身没有这样做的能力,所以我开始查看EnhancedGrid它本身具有的功能,并偶然发现moveColumn()grid.layout. 文档本身(这里)并不是很有用,但我用它把每一列都向前移动了一个位置,这样第一列就会变成最后一列。

我还制作了一个有效的 JSFiddle 来演示您可以在此处看到的内容。移动列的代码可以在代码底部找到:

for (var i = 1;i < grid.layout.cells.length;i++) {
    grid.layout.moveColumn(1, 1, i, i-1, grid.layout);
}

它的作用如下:它从索引 1 开始移动每一列,因此这意味着除了间接选择列之外的所有列都提前一步(i-1)。

于 2013-04-08T10:15:41.160 回答