Click here to Skip to main content
15,885,032 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear Friends,

I have a grid in which i have to display three columns:-

a. Unit
b. Unit Name
c. RecordCount (Sum of records pending for approval of a module.)

The record count takes time on page load so i moved the code for the same to different method. So first all the unit with unit names gets populated in grid with record count column as 0 and then i call the recordcount method which fills the record count for each record in third column. But the record count data fetching takes time so the page gets hang till the record count is filling in grid.

I want my recordcount method to be called asynchronously in javascript; so that user can perform operatios on screen and in behind the recordcount method fills he third column without hanging the page.

I am using farspread grid.
//Fill Unit Grid method
        function FillUnit() {
            //Modified and Added by: Varun Sareen on 21/09/2015 [start]
            //ret = clsSANApprovalWrapper.GetSANUnit(thisForm.hdnUnit.value.toUpperCase());
            ret = clsSANApprovalWrapper.GetSANUnit(thisForm.hdnUnit.value.toUpperCase(), thisForm.hdnMode.value.toUpperCase());
            //Modified and Added by: Varun Sareen on 21/09/2015 [end]
            if (ret.value != "") {
                ret = ret.value.split("#");
                if (ret[0] == "N") {
                    blur = "999";
                    alert("No SAN is pending for approval.");
                    IsSuperUser = ret[2];
                    document.getElementById("fldUnitID").style.display = "none";
                }
                else {
                    SetSANUnitData(ret[1]);
                    IsSuperUser = ret[2];
                    SetLegendUnitIDText(thisForm.hdnUnit.value.toUpperCase());
                    document.getElementById("fldUnitID").style.display = "block";
                    setTimeout(function() {
                        AlertAsync();
                    }, 1000);
                }
            }
            blur = "";
        }
        function AlertAsync(){
            ret = clsSANApprovalWrapper.GetSANCount(thisForm.hdnMode.value.toUpperCase());
            if (ret.value != "") {
                ret = ret.value.split("¬");
                if (ret[0] == "N") {
                }
                else {
                    var arrRet = ret[1].split("|")
                    for (var i = 1; i <= thisForm.grdSANUnit.MaxRows; i++) {
                        thisForm.grdSANUnit.Row = i;
                        thisForm.grdSANUnit.Col = enumSANUnit.ColUnitID;
                        for (var j = 0; j < arrRet.length - 1; j++) {
                            var arrData = arrRet[j].split("«");
                            if (trimStr(thisForm.grdSANUnit.value) == trimStr(arrData[0])) {
                                thisForm.grdSANUnit.Col = enumSANUnit.ColSANCount;
                                thisForm.grdSANUnit.value = trimStr(arrData[1])
                            }
                        }
                    }
                }
            }
        }


Please suggest some solution.

Thanks
Varun
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900