I just started using Kendo UI and did this tutorial to learn the basics, I created a new Kendo UI for MVC Web Application project on Visual Studio 202 and decided to put to test what I learned, I tried to put a Grid just like in the tutorial but failed to run it.
What I mean is that the kendo functions aren’t being recognized, which shouldn’t happen, since the project already has the kendo folder with the js files.
Here’s how my View looks like:
<!DOCTYPE html>
<html>
<head >
<link href="Content/kendo/2012.2.710/kendo.common.min.css" rel="stylesheet" type="text/css" />
<link href="Content/kendo/2012.2.710/kendo.default.min.css" rel="stylesheet" type="text/css" />
<title><%: ViewBag.Title %></title>
</head>
<body>
<h1><%: ViewBag.GestionTitle %></h1>
<div id="tweetGrid"></div>
<script src="Scripts/jquery-1.8.2.min.js"></script>
<script src="Scripts/kendo/2012.2.710/kendo.web.min.js"></script>
<script>
$(function () {
var ds = new kendo.data.DataSource({
transport: {
read: {
url: "http://search.twitter.com/search.json?q=kendoui",
dataType: "jsonp"
}
},
schema: {
data: "results"
}
});
$("#tweetGrid").kendoGrid({
columns: ["from_user", "from_user_name", "text"],
dataSource: ds
});
});
</script>
</body>
</html>
I’ve tried placing the scripts inside the head and inside the body, but can’t get the kendo functions to work. What am I missing?
Based on your comment…
The rendered HTML is referencing resource files in the wrong location, hence the 404 error(s). Keep in mind that a view by itself has no concept of what URL will render it. It seems that this view is being rendered under a
/Test/path. Since the script is being referenced with a relative path, it’s looking for that relative path. What version of MVC are you using? They changed the “right way” to reference view resources a couple of times.For example, you might reference the scripts like this:
This essentially calls on server-side pre-processing to determine the correct client-side path to the file (based on a server-side path relative to the application root) and output that path in the
scripttag. So no matter where the view is used, it should always have the correct path to the resource file.You’d want to do this with any page resources. JavaScript files, CSS files, even images where appropriate.