Error in very simple binding Grid to DataSource

3 posts, 0 answers
  1. Ivan Petrov
    Ivan Petrov avatar
    23 posts
    Member since:
    Nov 2009

    Posted 15 Jun 2012 Link to this post

    Hello! What's wrong with following code?

    <div id="grid"></div>
     
    <script type="text/javascript">
        $(function () {
     
            var units = [{ UnitId: 2 }, { UnitId: 5}];
     
            var ds = new kendo.data.DataSource({
                // transport: {
                //   read: { url: 'http://localhost:6356/admin/GetUnitTogglesList' }
                // },
                data: units
            });
     
            ds.read();                    // For test purpose:
            alert(ds.data().length);      // show 2 - it's Ok
     
            $('#grid').kendoGrid({
                dataSource: ds,
                columns: [{ title: "Unit Id", field: "UnitId"}]
            });
     
        });
    </script>

    In result - Grid is empty.
    And i see error in Firebug console (see attached image).
  2. Jerry T.
    Jerry T. avatar
    118 posts
    Member since:
    Jul 2012

    Posted 15 Jun 2012 Link to this post

    Do you need the ds.read(); ?

    Also, have you tried defining the id in a schema property for the data source?
  3. Kendo UI is VS 2017 Ready
  4. Ivan Petrov
    Ivan Petrov avatar
    23 posts
    Member since:
    Nov 2009

    Posted 19 Jun 2012 Link to this post

    Resolved.

    I use kendo.dataviz.min.js and kendo.web.js and error occurs if  web.js included before dataviz.js.

    I changed the order of the files and the problem disappeared.

    Correct order:

      <script src="kendo.dataviz.min.js" type="text/javascript"></script>
      <script src="kendo.web.js" type="text/javascript"></script>             // after dataviz!
Back to Top