0
votes
       $.ajax({
                type: "POST",
                url: "EmpService.asmx/GetEmployeeDetails",
                data: "",
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function (
                    $("#grid").kendoGrid({

                        dataSource: {
                            data: result.d
                            },
                        schema:{
                            data: "d"
                            },
                        columns: [{
                            field: "EMP_NAME",
                            title: "First Name"
                        },
                        {
                            field: "EMP_ID",
                            title: "ID"
                        }],
                    });

                },
                error: function (r) {
                    alert(r.responseText);
                },
                failure: function (r) {
                    alert(r.responseText);
                }
            });
        });

I calling a service using ajax call and returning a json data and I am trying to bind to it Kendo grid, but it's not binding. I have the json data returned from the service in the below format

[{"EMP_NAME":"E1","EMP_ID":1},{"EMP_NAME":"E2","EMP_ID":2},{"EMP_NAME":"E3","EMP_ID":3}]

but when I am trying in harcoded way like below the grid shows the details

dataSource: {
 data: [{"EMP_NAME":"E1","EMP_ID":1},{"EMP_NAME":"E2","EMP_ID":2},{"EMP_NAME":"E3","EMP_ID":3}]
   },
1
you defined in schema that response have data in "d" property, so response should look like this {"d": [{"EMP...."}]}, if not try to remove schema - dev_in_progress
Also did you try to console log reusult.d in success function? What dos it show? - dev_in_progress
have tried removing schema but still doesn't bind the grid, and yes I did console log and did get the same json format as above - thecrusader

1 Answers

0
votes

Try specifying schema inside your dataSource like this.

 dataSource: {
            data: gridData,
            schema: {
                model: model
            },
            pageSize: 10
        },