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

json data not binding to grid.

1 Answer 93 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jeremy
Top achievements
Rank 1
Jeremy asked on 25 Jan 2016, 02:51 AM

My grid that is bound to json data is not displaying the data. Here is my code.

<script>
        var remoteDataSource = new kendo.data.DataSource(
   {
       transport:
       {
           read: {
               type: "get",
               dataType: "json",
               url: "http://localhost:50411/EmployeeService.asmx/GetData",
               contentType: "application/json; charset=utf-8"
           }
       },
       pageSize: 4
   })
        $("#grid").kendoGrid(
            {
                dataSource: remoteDataSource,
                columns: [
                    {
                        field: "pin",
                        title: "PIN",
                        width: 600,
                        filterable: true
                    },
                    {
                        field: "firstName",
                        title: "First Name",
                        width: 100,
                        filterable: true
                    },
                    {
                        field: "lastName",
                        title: "Last Name",
                        filterable: true,
                    },
                ],
                schema: {
                    data: "list"
                },
                height: 430,
                scrollable: true,
                sortable: true,
                pageable: true,
            });
    </script>

Im using an asmx webmethod.

 [WebService(Namespace = "http://localhost/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]
    // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
    [System.Web.Script.Services.ScriptService]
    public class EmployeesService : System.Web.Services.WebService
    {

        [WebMethod]
        public static string GetData()
        {
            JavaScriptSerializer serializer = new JavaScriptSerializer();
            List<DepartmentEmployees> employees = EmployeeRules.GetDepartmentEmployeeses(Debug.GetEmployees(20));
            return serializer.Serialize(employees);
        }
    }

1 Answer, 1 is accepted

Sort by
0
Alexander Valchev
Telerik team
answered on 27 Jan 2016, 09:32 AM
Hi Jeremy,

Could you please provide a sample of the JSON response that comes from the server so I can examine its format and verify that the dataSource is configured correctly?

Looking forward to your reply.

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