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

getting error - Object doesn't support this property or method

1 Answer 173 Views
Grid
This is a migrated thread and some comments may be shown as answers.
satya
Top achievements
Rank 1
satya asked on 17 Oct 2012, 03:34 PM
While loading the grid, getting Object doesn't support this property or method
please find below for code,

aspx:
   $(document).ready(function () {
                $("#grid").kendoGrid({
                    dataSource: {
                        transport: {
                            read: function (options) {
                                $.ajax({
                                    type: "POST",
                                    url: "Default.aspx/GetEvents",
                                    contentType: "application/json; charset=utf-8",
                                    dataType: "json",
                                    success: function (msg) {
                                        options.success(msg.d);
                                    }
                                });
                            }
                        },
                        schema: {
                                model: {
                                    fields: {
                                        FirstName: { type: "string" },
                                        LastName: { type: "string" },
                                        City: { type: "string" }
                                    }
                                }
                            },
                            pageSize: 10
                    },
                    height: 250,
                    scrollable: true,
                    sortable: true,
                    filterable: true,
                    pageable: true,
                    columns: [
                            {
                                field: "LastName",
                                title: "LastName",
                                width: 100
                            },
                            {
                                field: "FirstName",
                                title: "FirstName",
                                width: 100
                            },
                             {
                                 field: "City",
                                 title: "City",
                                 width: 100
                             },
                            {
                                field: "Age",
                                title: "Age",
                                width: 100
                            }
                        ]
                });
            });


Web method :
 [WebMethod()]
    [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
    public static string GetEvents()
    {
        EventsOrg obj = new EventsOrg { FirstName = "Test", LastName = "11/22/1234", City = "tst", Age = "10" };
        List<EventsOrg> objEvent = new List<EventsOrg>();
        objEvent.Add(obj);
        EventsOrg obj1 = new EventsOrg { FirstName = "Test 1", LastName = "1/12/1993", City = "tst 1", Age = "10" };
        objEvent.Add(obj1);

        JavaScriptSerializer js = new JavaScriptSerializer();
        string strJSON = js.Serialize(objEvent);
        return strJSON;

        //  return new JavaScriptSerializer().Serialize(objEvent);
        // return objEvent;
    }

refrences JS :
  <link href="styles/examples-offline.css" rel="stylesheet" />
    <link href="styles/kendo.common.min.css" rel="stylesheet" />
    <link href="styles/kendo.default.min.css" rel="stylesheet" />
   <script src="js/jquery.min.js" type="text/javascript"></script>
    <script src="js/kendo.web.min.js" type="text/javascript"></script>
    <script src="js/console.js" type="text/javascript"></script>
    <script src="js/jquery-1.4.1.js" type="text/javascript"></script>

Please help me to identify the error for application

1 Answer, 1 is accepted

Sort by
0
John
Top achievements
Rank 1
answered on 23 Oct 2012, 12:59 AM
You don't have to serialize you collection into a JSON string since you have declared your GetEvents() function as a WebMethod.

Just return the list:

 public static List<EventsOrg> GetEvents()
    {
        EventsOrg obj = new EventsOrg { FirstName = "Test", LastName = "11/22/1234", City = "tst", Age = "10" };
        List<EventsOrg> objEvent = new List<EventsOrg>();
        objEvent.Add(obj);
        EventsOrg obj1 = new EventsOrg { FirstName = "Test 1", LastName = "1/12/1993", City = "tst 1", Age = "10" };
        objEvent.Add(obj1);

return objEvent;
}
Tags
Grid
Asked by
satya
Top achievements
Rank 1
Answers by
John
Top achievements
Rank 1
Share this question
or