This is a migrated thread and some comments may be shown as answers.

Data source for grid not working

1 Answer 15 Views
Data Source
This is a migrated thread and some comments may be shown as answers.
Alex
Top achievements
Rank 1
Alex asked on 27 Oct 2015, 02:00 PM

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();​

1 Answer, 1 is accepted

Sort by
0
Viktor Tachev
Telerik team
answered on 29 Oct 2015, 09:59 AM
Hello Alex,

I have replied to your query in the other thread you have submitted. I suggest we continue the conversation there.

Please avoid sending duplicate threads. This will enable us to keep better track of your support history and provide answers faster.

Regards,
Viktor Tachev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
Data Source
Asked by
Alex
Top achievements
Rank 1
Answers by
Viktor Tachev
Telerik team
Share this question
or