Urgent - Foreach iteration takes more time to display

I want to hide the grid row on check box is checked.
For that i have used onCheck event

monitoringApp.myRibbon.attachEvent(“onCheck”, function (rId, cInd, state) {

      var discrepancyValue = monitoringApp.myRibbon.isChecked('discrepancy') ? 1 : 0;
    var colIndexDiscrepancy = monitoringApp.conGrid.getColIndexById('DISCREPANCY');

    if(discrepancyValue==1) {
        monitoringApp.conGrid.forEachRow(function (id) {
            if (monitoringApp.conGrid.cells(id, colIndexDiscrepancy).getValue() == "No") {
               monitoringApp.conGrid.setRowHidden(id, true);
                
            }
        });
    }else{
        monitoringApp.conGrid.forEachRow(function (id) {

                monitoringApp.conGrid.setRowHidden(id, false);
               
        });

    }

});

But this for each iteration will take 3-4 minutes time to hide the grid row.Because total 650 row in the grid.
But if i reload the whole data with db it is displayed in 15 seconds.It will hide the rows.But if i export into excel it will not display the filtered data in excel instead of it is showing 650 data in excel.

For hide the row i am using in xml $control[$id]->setAttribute(“style”, “display: none;”);

Urgent.Thanks in advance

Please, try to wrap all your hiding function callings in the FAST mode:
https://docs.dhtmlx.com/grid__big_datasets_loading.html (check the bottom of the page)
It allows to unify several render operations without the intermidiate render process to increase the performance.