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

Problem to fill a KendoGrid

0 Answers 67 Views
Grid
This is a migrated thread and some comments may be shown as answers.
totoro
Top achievements
Rank 1
totoro asked on 25 Sep 2012, 12:38 PM
Hi!
I can't load information in json format in my KendoGrid... 
URL : http://dotnet.habitatpro-com.local/test.json
CODE:

<html>
<head>
    <title></title>
    <script type="text/javascript" src="Scripts/jquery-1.7.1.js"></script>
    <script type="text/javascript" src="Scripts/kendo.all.js"></script>

</head>
<body>
            <div id="example" class="k-content">
            <div id="grid"></div>

            <script type="text/javascript">
                $(document).ready(function () {
                    var crudServiceBaseUrl = "http://dotnet.habitatpro-com.local/test.json",
                        dataSource = new kendo.data.DataSource({
                            transport: {
                                read: {
                                    url: crudServiceBaseUrl,
                                    dataType: "jsonp"
                                },
                                parameterMap: function (options, operation) {
                                    if (operation !== "read" && options.models) {
                                        return { models: kendo.stringify(options.models) };
                                    }
                                }
                            },
                            batch: true,
                            pageSize: 30,
                            schema: {
                                model: {
                                    id: "ProductID",
                                    fields: {
                                        ProductID: { editable: false, nullable: true },
                                        ProductName: { validation: { required: true} },
                                        UnitPrice: { type: "number", validation: { required: true, min: 1} },
                                        Discontinued: { type: "boolean" },
                                        UnitsInStock: { type: "number", validation: { min: 0, required: true} }
                                    }
                                }
                            }
                        });

                    $("#grid").kendoGrid({
                        dataSource: dataSource,
                        pageable: true,
                        height: 400,
                        toolbar: ["create"],
                        columns: [
                            { field: "ProductName", title: "Product Name" },
                            { field: "UnitPrice", title: "Unit Price", format: "{0:c}", width: "150px" },
                            { field: "UnitsInStock", title: "Units In Stock", width: "150px" },
                            { field: "Discontinued", width: "100px" },
                            { command: ["edit", "destroy"], title: "&nbsp;", width: "210px"}],
                        editable: "popup"
                    });
                });
            </script>
        </div>


</body>
</html>





Do you have any suggestions ?

Thanks

No answers yet. Maybe you can help?

Tags
Grid
Asked by
totoro
Top achievements
Rank 1
Share this question
or