开发者

Cant get JQGrid loadComplete event to fire

I'm trying to simulate a click on the first cell after the grid is loaded. I already know how to accomplish this, but for some reason I can't get the "loadComplete" event to fire. I have added a simple function with a single alert to try it out, but even though the page loads with no probl开发者_JAVA百科em, I'm not getting the alert (and debugging shows the function is never called).

"gridComplete" is not working either.

I am using jgGrid 3.8.2

Any idea on what I'm doing wrong? I have posted my code below:

    $(document).ready(function () {
        $("#grid").jqGrid(
            {
                datatype: function () {
                    $.ajax(
                    {
                        type: "POST",
                        url: "Default.aspx/GetListOfPersons",
                        data: "{}",
                        contentType: "application/json; charset=utf-8",
                        dataType: "json",
                        success: function (jsondata, stat) {
                            if (stat == "success")
                                jQuery("#grid")[0].addJSONData(JSON.parse(jsondata.d));
                            else
                                alert("error");
                        }
                    });
                },
                jsonReader:
                {
                    root: "rows",
                    page: "page",
                    total: "total",
                    records: "records",
                    repeatitems: false,
                    id: "Id"
                },
                colModel: //Columns
                [
                    { name: 'FirstName', index: 'FirstName', width: 200, align: 'Left', label: 'First Name', editable: true },
                    { name: 'LastName', index: 'LastName', width: 300, align: 'Left', label: 'Last Name', editable: true },
                    { name: 'Age', index: 'Age', width: 50, align: 'Right', label: 'Age', editable: true }
                ],
                caption: "Personas",
                cellEdit: true,
                cellsubmit: 'clientArray',
                pager: "#pager",
                loadComplete: function () { alert("load complete"); }
            }
            ).navGrid('#pager', { edit: false, add: false, del: false, search: false }).navButtonAdd('#pager',
            {
                caption: "Save",
                onClickButton: function () {
                    var ret = $("#grid").getChangedCells('dirty');
                    var ret2 = JSON.stringify(ret);
                    $.ajax(
                    {
                        type: "post",
                        url: "Default.aspx/GetChangesBack",
                        data: '{"o":' + ret2 + '}',
                        contentType: "application/json; charset=utf-8",
                        dataType: "json"
                    }
                    );
                },
                position: "last"
            }
            );
    }
    );


Because you are calling $.ajax yourself, I don't think loadComplete should fire.

gridComplete should work, though.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜