fill out kendogrid

5 posts, 0 answers
  1. totoro
    totoro avatar
    5 posts
    Member since:
    Sep 2012

    Posted 25 Sep 2012 Link to this post

    Hi!

    I can't load information in json format in my KendoGrid... 
    url : http://dotnet.habitatpro-com.local/test.json  return json flux
    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
  2. OnaBai
    OnaBai avatar
    55 posts
    Member since:
    Aug 2012

    Posted 26 Sep 2012 Link to this post

    Try defining an error and success functions that display information about the problem (or not).
    I.e.: In the Datasource add:
    success: function(result) {
        alert("Success");
    },
    error: function(info) {
        alert("Error!");
        console.log("info", info);
    },
    and check what your browser console shows about the error.
  3. Kendo UI is VS 2017 Ready
  4. totoro
    totoro avatar
    5 posts
    Member since:
    Sep 2012

    Posted 27 Sep 2012 Link to this post

    Hi OnaBai,

    Thank you for your answer
    Error on firebug console :
    errorThrown     Error: jQuery18209097495959869581_1348749079551 was not called       
    throw new Error( msg );  jquery-1.8.2.js (line 477)

    This method vb return json flux:


        <WebMethod()> _
        <ScriptMethod(ResponseFormat:=ResponseFormat.Json)> _
        Sub ReturnJsonTest()
            Dim strbdd As Object = "[{""ProductID"":1,""ProductName"":""Chai"",""UnitPrice"":18,""UnitsInStock"":39,""Discontinued"":false},     {""ProductID"":2,""ProductName"":""Chang"",""UnitPrice"":19,""UnitsInStock"":17,""Discontinued"":false},{""ProductID"":3,""ProductName"":""Aniseed Syrup"",""UnitPrice"":10,""UnitsInStock"":13,""Discontinued"":false},{""ProductID"":4,""ProductName"":""Chef Anton\u0027s Cajun Seasoning"",""UnitPrice"":22,""UnitsInStock"":53,""Discontinued"":false}]"
            Context.Response.ContentType = "application/json"
            Context.Response.Write(strbdd)
            Context.Response.End()
        End Sub


    I really don't see where is the problem .. callback maybe?
    Thanks for investigating
  5. OnaBai
    OnaBai avatar
    55 posts
    Member since:
    Aug 2012

    Posted 27 Sep 2012 Link to this post

    You say: "This method vb return json flux" and Context.Response.ContentType = "application/json"
    But you datasource says jsonP.  Is your datatype JSON or JSONP?


  6. totoro
    totoro avatar
    5 posts
    Member since:
    Sep 2012

    Posted 27 Sep 2012 Link to this post

    When i use "application/jsonp" i have the same problem with error in firebug console...and there is a window which propose if i want download my json flux... =_='
Back to Top
Kendo UI is VS 2017 Ready