Data Grid - Column Display Control

In this example, we focus on two commands (showColumn(colnum) and hideColumn(colnum)). These commands allows developers to programmatically show or hide column after the data grid is constructed and displayed.

    Syntax: myGrid.showColumn(colnum);

    Syntax: myGrid.hideColumn(colnum);

In this example, both showColumn and hideColumn are executed from the function named setColumnVisible. The function retrieve the value (0 - n-1) from a dropdown list and execute either show or hide column depending on the boolean value in visible.

    function setColumnVisible (aObj, visible){
        var colnum = aObj.options[aObj.selectedIndex].value;
        if(visible == true)
            myGrid.showColumn(colnum);
        else
            myGrid.hideColumn(colnum);
    }