Hide columns with no or 0 values p

I have a grid thats pretty wide. I have 20 columns - some of which may sum to 0.  If they have no values if like to hide them to make the grid easier to read.  Is there such a way to do this?


1 Reply

TS Thiyagu Subramani Syncfusion Team June 8, 2020 02:49 PM UTC

Hi Rich, 

By default we have an option for visible to achieve your requirement. Here we have hided EmployeeID (value as 0) column using QueryCellInfo event. Please refer to the below code and sample link. 

var flag = true; 
    function queryCellInfo(args) { 
        debugger; 
        var gridObj = document.getElementsByClassName('e-grid')[0].ej2_instances[0]; 
        if (flag) { 
            if (args.data.OrderID === 10001 && args.data[args.column.field] === 0) { // Hided EmployeeID column 
                args.column.visible = false; 
                flag = false; 
                gridObj.refreshColumns(); 
            } 
        } 
    } 



Please get back to us, if you need any further assistance. 

Regards, 
Thiyagu S 


Loader.
Up arrow icon