0
votes

I'm having a problem updating a Kendo Listview using a button.
The SubTasks_Read function is called in the code behind and returns data from wcf, but the listview doesnt change when i bind it. Please help!!

Here is my code:

<div class="subtasks-div">
    <div class="section-header">
        <p>Subtasks</p>
    </div>
    @(Html.Kendo().ListView<Origin.Web.AdminProxy.SubTask>(Model.SubTaskList)
        .Name("subtask-listView")
        .TagName("div")
        .ClientTemplateId("subtask-template")
        .DataSource(dataSource =>
        {
            dataSource.Read(read => read.Action("SubTasks_Read", "WorkFlow"));
            dataSource.PageSize(15);
        })
        .Selectable(selectable => selectable.Mode(ListViewSelectionMode.Single))
    )
</div>

<script>
 $(function () {
     $("#refresh-button")
     .button()
     .click(function (event) {

         var subTaskDataSource = new kendo.data.DataSource({
             transport: {
                 read: {
                     type: "GET",
                     url: "../WorkFlow/SubTasks_Read/?taskId=2",
                     dataType: "jsonp"
                 },

             },

             schema: {
                 model: {
                     fields: {
                         subTaskId: { type: "number" },
                         taskId: { type: "number" },
                         subTaskName: { type: "string" },
                         subTaskOrder: { type: "number" }
                     }
                 }
             }
         });


         $("#subtask-listView").kendoListView({
             dataSource: subTaskDataSource
         });

     });
 });
1

1 Answers

0
votes

Your code has a few problems:

  1. It creates a JSONP data source while your action method probably returns JSON (there is a difference).
  2. Your code recreates the ListView which is not needed.

I recommend simply calling the read method of the current list view data source.

$("#refresh-button")
 .button()
 .click(function (event) {
     $("#subtask-listView").data("kendoListView").dataSource.read();
 });