Data source for grid not working

2 posts, 0 answers
  1. Alex
    Alex avatar
    7 posts
    Member since:
    Oct 2015

    Posted 27 Oct 2015 Link to this post

    HI Telerik Team,

     I am trying to populate grid using datasource. but the grid is not populating

     

    asmx
     
     [WebMethod]
            [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
            public string GetTasks1()
            {
                JavaScriptSerializer theSerializer = new JavaScriptSerializer();
                   string result = "";
                    List<rt_aw_user_task_details> resultList = new List<rt_aw_user_task_details>();
     
                    AW_USER_TASK_DETAILS taskDetails = new AW_USER_TASK_DETAILS();            
                    taskDetails.Query.Load();
     
                    resultList = taskDetails.ToRemotableList();           
     
                    var data = resultList.Select(i => new { i.seq_no, i.task_id, i.category }).ToList();
                    result =  new JavaScriptSerializer().Serialize(data);
                    return result;          
            }​
     
    aspx page
     
      $(document).ready(function () {​
     
                var tasksDataSource = new kendo.data.DataSource({
                    type: "json",
                    serverFiltering: true, serverPaging: true,  serverSorting: true,  pageSize: 10,
                    transport: {
                        read: {
                            datatype: "json",
                            type: "POST",
                            url: "Service/MyTasks.asmx/GetTasks"
                        }
                    }
                });
     
                tasksDataSource.read();
     
                $("#grid").kendoGrid({
                    dataSource: tasksDataSource,
                    height: 400,
                    groupable: true,
                    sortable: true,
                    pageable: {
                        refresh: true,
                        pageSizes: true,
                        buttonCount: 5
                    },
                    columns: [{
                        field: "seq_no",
                        title: "CATEGORY"
                    }, {
                        field: "task_id",
                        title: "FREQUENCY"
                    }, {
                        field: "category",
                        title: "ISANYTIME",
                    }]
                });
     
          });

     The grid is not loading.......

    Is there anything i am missing??

     

    and the service returns the following data

    [{ "seq_no": 2, "task_id": 96, "category": "Task" }, { "seq_no": 3, "task_id": 92, "category": "Report To Review" },
                    { "seq_no": 4, "task_id": 99, "category": "Meeting" }, { "seq_no": 5, "task_id": 96, "category": "Task" },
                    { "seq_no": 6, "task_id": 96, "category": "Task" }, { "seq_no": 7, "task_id": 93, "category": "Report To Send" },
                    { "seq_no": 8, "task_id": 99, "category": "Meeting" }, { "seq_no": 9, "task_id": 96, "category": "Task" },
                    { "seq_no": 10, "task_id": 96, "category": "Task" }, { "seq_no": 11, "task_id": 99, "category": "Meeting" }]

     

    But it is working when I give the data directly

     

    var tasksDataSource = new kendo.data.DataSource({
                    data: [
                    { "seq_no": 2, "task_id": 96, "category": "Task" }, { "seq_no": 3, "task_id": 92, "category": "Report To Review" },
                    { "seq_no": 4, "task_id": 99, "category": "Meeting" }, { "seq_no": 5, "task_id": 96, "category": "Task" },
                    { "seq_no": 6, "task_id": 96, "category": "Task" }, { "seq_no": 7, "task_id": 93, "category": "Report To Send" },
                    { "seq_no": 8, "task_id": 99, "category": "Meeting" }, { "seq_no": 9, "task_id": 96, "category": "Task" },
                    { "seq_no": 10, "task_id": 96, "category": "Task" }, { "seq_no": 11, "task_id": 99, "category": "Meeting" }]
                });
     
                tasksDataSource.read();​

  2. Viktor Tachev
    Admin
    Viktor Tachev avatar
    1488 posts

    Posted 29 Oct 2015 Link to this post

    Hi Alex,

    Please remove the type setting for the dataSource. Also make sure that the server operations are configured as described in the following article. Note that the schema.total should be set when serverPaging is true.



    Regards,
    Viktor Tachev
    Telerik
     
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
     
  3. Kendo UI is VS 2017 Ready
Back to Top