tabalinas/jsgrid

initializing grid on done of ajax request throws "jsGrid is not a function" error

开放

#970 创建于 2017年12月6日

 (3 条评论) (0 个反应) (0 位负责人)JavaScript (356 个派生)batch import
help wanted

仓库指标

星标
 (1,520 个星标)
PR 合并指标
 (30 天内没有已合并 PR)

描述

Hi!

I have been trying to make this work and somehow it doesn't. The code is just initializing the jsGrid on the "done" of the ajax call, as follows (I have simplified the grid, I am only showing the one column I want to bind):

    $.ajax({
               method: "GET",
               url: "/User/GetList"
           }).done(function (users) {

             console.log("data from ajax call:", users);

            $("#jsGrid").jsGrid({

                width: "900px",
                height: "700px",

                filtering: true,
                inserting: true,
                editing: true,
                sorting: true,
                paging: true,
                autoload: true,

                pageSize: 10,
                pageButtonCount: 5,

                deleteConfirm: "Do you really want to delete client?",
                controller: {
                    loadData: function (filter) {
                        return $.ajax({
                            type: "GET",
                            url: "/X/GetList",
                            data: filter
                        });
                    },
                    insertItem: function (item) {
                        return $.ajax({
                            type: "POST",
                            url: "/X/Create",
                            data: item
                        });
                    },
                    updateItem: function (item) {
                        return $.ajax({
                            type: "PUT",
                            url: "/X/Update",
                            data: item
                        });
                    },
                    deleteItem: function (item) {
                        return $.ajax({
                            type: "DELETE",
                            url: "/X/Delete",
                            data: item
                        });
                    }
                },
                fields: [
                    { name: "UserName", type: "select", width: 300, items: users, valueField: "ID", textField: "UserName" },
                    { type: "control" }
                ]
            });
        });

Now, the result is the following:

image

What could be the issue? I have tried everything, but it only works if the array passed on items is a static one. I did check issue #15 already, as well as this example.

Thanks!

贡献者指南