Jaffa
Jaffa

Reputation: 37

Kendo: bind remote datesource to form

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?

Upvotes: 2

Views: 273

Answers (1)

CMartins
CMartins

Reputation: 3293

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);
    }

});

Upvotes: 0

Related Questions