Kendo: bind remote datesource to form

倾然丶 夕夏残阳落幕 提交于 2019-12-11 01:17:11

问题


I am trying to understand how I can bind data from a remote datasource to a form, similar to this question, my ajax is returning the correct data.

I have tried to implement the suggested solution but it doesn't appear to work and there are no errors either.

my ajax request:

$.ajax({
    url: "Read?messageID=" + "123456",
    method: "get",
    type: "application/json",
    success: function (result) {
        console.log(result);
    },
    error: function (result) {
        console.log(result);
    }

})

I do not know how to extract the response from the read data and display it in my simple form.

If anyone could kindly give me some pointers, I would be so grateful. I have read a lot of posts on both SO and the Telerik forums but I have not been able to understand how to overcome my problem.

Many thanks


Edit:

This is my form field:

@Html.Label("message", "Note:", new { @class = "form-label" })
<input id="messages" class="form-control k-textbox" data-bind="value:message" />

Do I need to add a viewModel?


回答1:


For kendo Datasource here is a sample

    $.ajax({
    url: "Read?messageID=" + "123456",
    method: "get",
    type: "application/json",
    success: function (result) {
        var dataSource = new kendo.data.DataSource({
            data: result
        });
        console.log(result);
    },
    error: function (result) {
        console.log(result);
    }

});


来源:https://stackoverflow.com/questions/57939525/kendo-bind-remote-datesource-to-form

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!