dgrid OnDemandGrid在第一次加载时不显示数据

时间:2015-06-22 22:29:17

标签: javascript dojo dgrid

我有一个网格,我想在页面加载时填充数据。当我通过其他功能刷新网格或单击任何排序时,它工作正常,但它在页面首次加载时不显示数据。代码如下:

        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 个答案:

没有答案