Search code examples
dojox.grid

How to delete a column in dojox/grid/EnhancedGrid


Do we have any way to delete a column in dojox/grid/EnhancedGrid. Please let us know if there is any solution for this.

Please find my sample grid.
Details: it creates a dojox/grid/EnhancedGrid and has an action associated with clicking a header row. What action can I add to delete the column?

var dataStore = new ObjectStore({objectStore: objectStoreMemory});
// grid
grid = new EnhancedGrid({
    selectable: true,
    store: dataStore,
    structure : [ {
        name : "Country",
        field : "Country",
        width : "150px",
        reorderable: false,
        editable : true
    }, {
        name : "Abbreviation",
        field : "Abbreviation",
        width : "120px",
        reorderable: false,
        editable : true
    }, {
        name : "Capital",
        field : "Capital",
        width : "100%",
        reorderable: false,
        editable : true
    } ],
    rowSelector: '20px',
    plugins: {
        pagination: {
            pageSizes: ["10", "25", "50", "100"],
            description: true,
            sizeSwitch: true,
            pageStepper: true,
            gotoButton: true,
            maxPageStep: 5,
            position: "bottom"
        }
    },
    dodblclick: function() {
        alert("Header clicked");  
    }
}, "grid");
grid.startup();

Solution

  • you need to use the method

    grid.setStructure(newLayout); 
    

    or

    grid.set('structure',newLayout); 
    

    here newLayout is the layout that you need to create without the columns that you need. Hope this helps.