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

Unable to get property 'DataSource' of undefined or null reference

1 Answer 558 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Turlough
Top achievements
Rank 1
Turlough asked on 13 Nov 2012, 12:45 PM

I want to bind to a controller called articles but am getting an exception as follows
0x800a138f - JavaScript runtime error: Unable to get property 'DataSource' of undefined or null reference


<!DOCTYPE html >

<HTML>
<head>
    <title>content</title>
    <link href="~/Content/kendo/2012.2.710/kendo.common.min.css" rel="stylesheet" />
    <link href="~/Content/kendo/2012.2.710/kendo.default.min.css" rel="stylesheet" />

</head>
    <body>
        <div id="articlesgrid"> </div>

        <script src="~/Scripts/jquery-1.7.2.js"></script>
        <script src="~/Scripts/kendo/2012.2.710/kendo.web.min.js"></script>
        <script>
            $(function()
            {
                $("#articlesgrid").kendoGrid(
                    {
                        dataSource: new kendo.Data.DataSource({
                            transport: {
                            read : "Api/Articles"
                        }}
                        )
                    })
                }
            );

        </script>
    </body>
</HTML>

 

#''''''''''''''''''''''''''''''''''''''''''''''''''''''''

 public class ArticlesController : Controller
    {
       public List<Article> Get()
        {
            List<Article> lst = new List<Article>();
            lst.Add(new Article() { ID = 1, Name = "AAA", Price1 = 1.22m });
            lst.Add(new Article() { ID = 1, Name = "BBB", Price1 = 1.32m });
            lst.Add(new Article() { ID = 1, Name = "CCC", Price1 = 1.42m });

            return lst;
        }
    }
}

 

 

1 Answer, 1 is accepted

Sort by
0
Accepted
Vladimir Iliev
Telerik team
answered on 15 Nov 2012, 10:41 AM
Hi Turlough,

 

After reviewing the provided example it seems that the issue comes from invalid dataSource definition - 
the "kendo.data" must be typed with lowercase letters. Please check the updated example below:

$(function()
{
    $("#articlesgrid").kendoGrid(
        {
            dataSource: new kendo.data.DataSource({
                transport: {
                read : "Api/Articles"
            }}
            )
        })
    }
);
Kind Regards,
Vladimir Iliev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Grid
Asked by
Turlough
Top achievements
Rank 1
Answers by
Vladimir Iliev
Telerik team
Share this question
or