Question

I am creating the dojo Grid as below and I am using the indirectSelection plugin for creating a checkbox, as below, but by default the checkboxes will come at the first column of the grid. How do I make it to come at the last column?

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();
});
Was it helpful?

Solution

The plugin itself has no capabilities of doing so as far as I know so I started looking at the functions the EnhancedGrid itself has and stumbled upon the function moveColumn() in grid.layout. The documentation itself (here) was not really usefull, but I used it to move every column one position ahead so that the first column would become the last one.

I also made a working JSFiddle to demonstrate which you can see here. The code that is moving the columns can be found at the bottom of the code:

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

What it does is the following: it moves every column starting from index 1, so that means all columns except the indirectSelection column one step ahead (i-1).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top