0

我试图在 kendoWindow 中显示一个网格,但该网格没有显示出来。这是我的html

<div id="ShowPrompts">
    <div id="PromptsGrid">

    </div>
</div>

当在 detailGrid 中单击一行时,我发生了这一切,它传递了 GroupID 和 OptionID,这就是函数

function GetThePromptsData(gid, oid) {
    $.ajax({
        type: "GET",
        url: URLParams.PromptsData + "?globalgroupID=" + gid + "&optionid=" + oid,
        dataType: "json",
        contentType: "application/json; charset=utf-8",
        success: function (data, textStatus, jqXHR) {
            CreatePromptsGrid(data);
            ShowPromptsPopUp();
        }
    });
}

这是 ShowPromptsPopUp() 函数

function ShowPromptsPopUp() {
    $("#ShowPrompts").kendoWindow({
        width: "300px",
        height: "300px",
        title: "Option Prompts",
        visible: false,
        modal: true,
        actions: [
            "Close"
        ]
    }).data("kendoWindow").center().open();
}

我检查过,JsonResult 中有数据,但不想显示在窗口中。

编辑

我再次运行它,当我显示它时,窗口不会出现,所以我从 GetThePromptsData() 中删除了 ShowPromptsPopUp() 并将其放置在 detailGrid 的更改事件中,窗口出现但仍然没有网格窗户。

在 detailGrid 更改事件中,顺序是这样的

GetThePromptsData(globalID, optionID);
ShowPromptsPopUp();

编辑 2

var promptGrid,
CreatePromptsGrid = function (promptsData) {
    promptGrid = $("#PromptsGrid").kendoGrid({
        dataSource: {
            promptsData
        },
        schema: {
            model: {
                id: "PromptID",
            }
        },
        columns: [
            { field: "Question", title: "Question" },
            { field: "DefaultAnswer", title: "Answer" }
        ],
        change: function (e) {

        },
        scrollable: true,
        pageable: false,
        selectable: "row"
    }).data("KendoGrid");
}
4

1 回答 1

0
I have modified the code little and its working. please check:
function GetThePromptsData() {
   /* $.ajax({
        type: "GET",
        url: "http://jsonplaceholder.typicode.com/posts",
        dataType: "jsonp",
        contentType: "application/json; charset=utf-8",
        success: function (data, textStatus, jqXHR) {

        }
    });*/
    data =[ {
    PromptID:1,
    Question:"test 1",
    DefaultAnswer:"test answer 1" 

    },
    {
    PromptID:2,
    Question:"test 2",
    DefaultAnswer:"test answer 2"    

    },
    ]
     CreatePromptsGrid(data);
      ShowPromptsPopUp();
}

function ShowPromptsPopUp() {
    $("#ShowPrompts").kendoWindow({
        width: "300px",
        height: "300px",
        title: "Option Prompts",
        visible: false,
        modal: true,
        actions: [
            "Close"
        ]
    }).data("kendoWindow").center().open();
}

var promptGrid,
CreatePromptsGrid = function (promptsData) {
    promptGrid = $("#PromptsGrid").kendoGrid({
        dataSource: {
            data:promptsData
        },
        schema: {
            model: {
                id: "PromptID",
            }
        },
        columns: [
            { field: "Question", title: "Question" },
            { field: "DefaultAnswer", title: "Answer" }
        ],
        change: function (e) {

        },
        scrollable: true,
        pageable: false,
        selectable: "row"
    }).data("KendoGrid");
}

GetThePromptsData();
于 2016-03-10T07:04:45.833 回答