dgrid OnDemandGrid not showing data on first load

636 views Asked by At

I have a grid that I want to populate with data when the page loads. It works fine when I refresh the grid through other functions or when I click any of the sorting, but it doesn't show the data when the page first loads. Code is below:

        GetSpecGridInfo = function () {
        var ddlg = dijit.byId('ddlSection');
        var groupid = ddlg.get('value');
        serverpath = dijit.byId('callbackpath2').value;
        var xmlhttp = new XMLHttpRequest();
        xmlhttp.open("GET", serverpath + "Controller/Spec?SectionID=" + groupid + "&r=" + r, true);
        xmlhttp.send();
        if (specGridStore.data.length > 0) {
            var sLength = specGridStore.data.length;
            for (var g = 0; g < sLength; g++) {
                specGridStore.remove(specGridStore.data[0]._id);
            }
            grid.refresh();
        }

        xmlhttp.onreadystatechange = function () {
            if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
                SpecData = JSON.parse(xmlhttp.responseText);
                specGridStore = new Memory({ data: SpecData, idProperty: "_id" });

                grid.refresh();
                r++;
            }


            grid = new (declare([OnDemandGrid, Keyboard, Editor, Selection, ColumnHider]))({
                bufferRows: Infinity,
                collection: regspecGridStore,
                columns: [
                   { field: "_id", label: "ID", hidden: true },
                   { field: "_SpecSectionID", label: "SpecID", hidden: true },
                   { label: "Name", field: "_name" },
                   { field: "_number", label: "Number" },
                   { field: "_description", label: "Description" },
                   { field: "_allApp", label: "Application" },
                   { field: "_allMat", label: "Materials" },
                   { field: "_url", label: "URL" }
                ]
            }, "editGrid");

            grid.on('.dgrid-content .dgrid-cell:dblclick', function (event) {
                event.preventDefault();
                if (flag % 3 == 0) {
                    var cell = grid.cell(event);
                    showDialogEditSpec(cell);
                }
                flag++;

            });




    }
0

There are 0 answers