I have a list view that uses a datasource (see list view code below). Loads, works fine, no errors. When you click on an item in the list view, it redirects the URL to another page. After that redirected page shows up, a half-second later an error comes in the console that isn't very useful (see error below). After much tracing it seems that the error is being generated by the list view code which has since been unloaded because of the redirect.
Do I need to unregister/destroy datasources and widgets somehow before I redirect a page? Or some other problem? Apologies it's vague, very hard to debug.
Any help appreciated.
Cheers,
Brett
ListView Code:
$("#solutions-gallery-id").kendoListView({
dataSource: solutionsDataSource,
selectable: true,
template: kendo.template($("#solution-card-template-id").html()),
change: function(e){
var selectedIndex = this.select().index();
var dataItem = this.dataSource.view()[selectedIndex];
window.location = window.location.protocol + "//" + window.location.host + "/solution/" + dataItem.solution_id;
}
});
Error:
kendo.all.js:186 Uncaught TypeError: Cannot read property 'replace' of undefined
at Object.compile (kendo.all.js:186)
at Object.d [as template] (jquery.min.js:2)
at init.<
anonymous
> (4:489)
at Object.i (kendo.all.js:7415)
at Object.<
anonymous
> (jquery.min.js:2)
at i (jquery.min.js:2)
at Object.fireWith [as resolveWith] (jquery.min.js:2)
at Object.e.(anonymous function) [as resolve] (http://localhost:3000/javascripts/jquery.min.js:2:29192)
at success (kendo.all.js:6980)
at Object.i.success (kendo.all.js:5911)
compile @ kendo.all.js:186
d @ jquery.min.js:2
(anonymous) @ 4:489
i @ kendo.all.js:7415
(anonymous) @ jquery.min.js:2
i @ jquery.min.js:2
fireWith @ jquery.min.js:2
e.(anonymous function) @ jquery.min.js:2
success @ kendo.all.js:6980
i.success @ kendo.all.js:5911
i @ jquery.min.js:2
fireWith @ jquery.min.js:2
y @ jquery.min.js:4
c @ jquery.min.js:4
XMLHttpRequest.send (async)
send @ jquery.min.js:4
ajax @ jquery.min.js:4
read @ kendo.all.js:5914
(anonymous) @ kendo.all.js:6975
d @ jquery.min.js:2
_queueRequest @ kendo.all.js:7190
_dequeueRequest @ kendo.all.js:7202
success @ kendo.all.js:7072
success @ kendo.all.js:6979
i.success @ kendo.all.js:5911
i @ jquery.min.js:2
fireWith @ jquery.min.js:2
y @ jquery.min.js:4
c @ jquery.min.js:4
XMLHttpRequest.send (async)
send @ jquery.min.js:4
ajax @ jquery.min.js:4
read @ kendo.all.js:5914
(anonymous) @ kendo.all.js:6975
_queueRequest @ kendo.all.js:7190
read @ kendo.all.js:6968
(anonymous) @ 4:591
i @ jquery.min.js:2
fireWith @ jquery.min.js:2
ready @ jquery.min.js:2
K @ jquery.min.js:2
Hello all,
I'd like to know how to pass a parameter to an event handler registered inside a template. In my case, how to pass EmployeeID to myFunc()? I have tried onclick='myFunc(EmployeeID)' and onclick='myFunc(#: EmployeeID#)' and onclick='myFunc(#= EmployeeID #)' , but none of them works.
<script type="text/x-kendo-template" id="emp_list_template">
<div class="product">
<img src="@Url.Content("~/content/shared/images/employees/")#: EmployeeID #.png" alt="#: EmployeeID #" />
<a href='' onclick='myFunc(EmployeeID)'>Download</a>
</div>
</script>
Thanks.
We have a number of grids with a remote datasource, and on the "Add Record" functionality, you see the new record get inserted into the grid, and get passed to the editing template, but no Create event is sent to via the remote transport until you actually accept on the editor. However, when we set up a ListView with a remote datasource and a "New" button, similar to your demo, the transport's remote Create event seems to fired immediately with the editing template. This is obviously a problem because the fields haven't been filled in, and also a remote record is being created before we know if we want that or not.
Does ListView behave differently than Grid with a remote datasource when adding a record? I can't see where this would be desired behaviour, or if it is, how it would be turned off. I can't seem to see how we might have messed up defining the datasource. You have a demo with add/edit and one with remote datasource, but not both together, and we're going to try and merge them to give an running example of what we are seeing.
Hi,
I am using KendoUI for javascript angular directive. I have a list of tree object like:
dc.DataSource=[{Name:"Item1",Children:[{Name:"Item1.1"},{Name:"Item1.2"}]},
{Name:"Item2",Children:[{Name:"Item2.1"},{Name:"Item2.2"}]}
];
What I want to achieve is show each object in datasource in a listview template, and inside the template, I want to use tree view to display the hierarchical data(and a checkbox for each item data). In below code, I just want to know how to set the datasource of the treeview since it is different for each item
<div kendo-list-view k-data-source="dc.DataSource">
<div k-template>
<div class="col-md-3">
<div kendo-tree-view="tree" k-data-source="{{dataItem}}">
<span k-template>
{{dataItem.Name}}
</span>
</div>
</div>
</div>
</div>
Thanks,
Ziff
Hello,
from a database I get some strings with html included, ie. for links.
In the Dojo I simulate the remote result in the array data. But the html code is not rendered.I read some help sites about templates, but I found only solutions with constant html text in the template. And not inside remote results.
Regards,
Peter
The following code is also available in the dojo at http://dojo.telerik.com/@larkydoo/OGeYi. What I need to be able to do is to iterate through my Authors list within the template. I've tried a few variations without any luck. Help?
Thanks!
Here's the code:
<!DOCTYPE html>
<html>
<head>
<style>html { font-size: 12px; font-family: Arial, Helvetica, sans-serif; }</style>
<title></title>
<link rel="stylesheet" href="http://cdn.kendostatic.com/2015.1.429/styles/kendo.common.min.css" />
<link rel="stylesheet" href="http://cdn.kendostatic.com/2015.1.429/styles/kendo.default.min.css" />
<link rel="stylesheet" href="http://cdn.kendostatic.com/2015.1.429/styles/kendo.dataviz.min.css" />
<link rel="stylesheet" href="http://cdn.kendostatic.com/2015.1.429/styles/kendo.dataviz.default.min.css" />
<script src="http://cdn.kendostatic.com/2015.1.429/js/jquery.min.js"></script>
<script src="http://cdn.kendostatic.com/2015.1.429/js/angular.min.js"></script>
<script src="http://cdn.kendostatic.com/2015.1.429/js/kendo.all.min.js"></script>
</head>
<body>
<script src="../content/shared/js/products.js"></script>
<div id="example" ng-app="KendoDemos">
<div ng-controller="MyCtrl">
<div class="demo-section">
<div kendo-list-view id="listView" k-data-source="source">
<div class="product" k-template>
<h3>#:Title#</h3>
<p>#:Publisher#</p>
<p>#:AuthorsList#</p>
<div ng-repeat="author in #=Authors#">Display FullName Here: {{FullName}}</div>
</div>
</div>
</div>
</div>
</div>
<script>
angular.module("KendoDemos", [ "kendo.directives" ])
.controller("MyCtrl", function($scope){
$scope.source = new kendo.data.DataSource({
data: [
{
"$id": "1",
"ResourceId": 720,
"Title": "Volleyed and Thundered: A Short, Brutal History of War",
"AuthorsList": "Alfred Lloyd Tennyson",
"Publisher": "University of Hard Knocks",
"Authors": [
{
"$id": "2",
"AuthorId": 0,
"ResourceId": 0,
"FullName": "Alfred Lloyd Tennyson",
"IsApproved": false,
"FriendlyPath": "alfred_lloyd_tennyson"
}
]
},
{
"$id": "3",
"ResourceId": 867,
"Title": "Explorations in Imagination",
"AuthorsList": "Vladimir Nabokov, Robert Frost, Virginia Woolf, Ursula LeGuin, and Philip K. Dick",
"Publisher": "University of the Universe",
"Authors": [
{
"$id": "4",
"AuthorId": 0,
"ResourceId": 0,
"FullName": "Vladimir Nabokov",
"IsApproved": false,
"FriendlyPath": "vladimir_nabokov"
},
{
"$id": "5",
"AuthorId": 0,
"ResourceId": 0,
"FullName": "Robert Frost",
"IsApproved": false,
"FriendlyPath": "robert_frost"
},
{
"$id": "6",
"AuthorId": 0,
"ResourceId": 0,
"FullName": "Virginia Woolf",
"IsApproved": false,
"FriendlyPath": "virginia_woolf"
},
{
"$id": "7",
"AuthorId": 0,
"ResourceId": 0,
"FullName": "Ursula LeGuin",
"IsApproved": false,
"FriendlyPath": "ursula_leguin"
},
{
"$id": "8",
"AuthorId": 0,
"ResourceId": 0,
"FullName": "Philip K. Dick",
"IsApproved": false,
"FriendlyPath": "philip_k_dick"
}
]
},
{
"$id": "9",
"ResourceId": 1031,
"Title": "Stories from Everywhere",
"AuthorsList": "Tobias Wolfe, George Orwell, Ray Bradbury, Doctor Seuss, and Wallace Stevens",
"Publisher": "All Around U",
"Authors": [
{
"$id": "10",
"AuthorId": 0,
"ResourceId": 0,
"FullName": "Tobias Wolfe",
"IsApproved": false,
"FriendlyPath": "tobias_wolfe"
},
{
"$id": "11",
"AuthorId": 0,
"ResourceId": 0,
"FullName": "George Orwell",
"IsApproved": false,
"FriendlyPath": "george_orwell"
},
{
"$id": "12",
"AuthorId": 0,
"ResourceId": 0,
"FullName": "Ray Bradbury",
"IsApproved": false,
"FriendlyPath": "ray_bradbury"
},
{
"$id": "13",
"AuthorId": 0,
"ResourceId": 0,
"FullName": "Doctor Seuss",
"IsApproved": false,
"FriendlyPath": "doctor_seuss"
},
{
"$id": "14",
"AuthorId": 0,
"ResourceId": 0,
"FullName": "Wallace Stevens",
"IsApproved": false,
"FriendlyPath": "wallace_stevens"
}
]
}
]
});
$scope.onClick = function(e) {
alert(1);
}
})
</script>
</body>
</html>
I have hooked up a datasouce (with serverPaging: true) to both a listview and a pager.
The server returns the correct number of records (and an int indicating the total number of records) from the initial db query, however the pager's navigation buttons are disabled, as if the pager doesn't recognise the datasource.schema.total.
Is the combination datasource with serverPaging:true, listview and pager possible?
var ds = new window.kendo.data.DataSource({
transport: {
read: {
type: "POST",
url: url,
data: function () {
return {
country: 1
};
},
dataType: "json",
contentType: "application/json; charset=utf-8"
},
parameterMap: function (data) {
return JSON.stringify(data);
}
},
serverPaging: true,
schema: {
model: {
id: "id",
fields: {
id: { type: "number" },
field1: { type: "string" },
field2: { type: "string" }
}
},
total: 'total'
},
pageSize: 50
});
$("#list").kendoListView({
dataSource: ds,
template: window.kendo.template($("#tmpl").html())
});
$("#pictures-pager").kendoPager({
dataSource: ds,
numeric: false,
refresh: true,
messages: {
display: "{0}-{1} / {2}",
empty: "",
itemsPerPage: ""
},
pageSizes: [10, 50, "all"]
});
Hi,
In some of my listviews I'd like to alternate item color and find myself using almost identical templates in the template and altTemplate properties.
template:
<script id="template" type="text/x-kendo-template">
<div class="regular-color">#:value#</div>
</script>
altTemplate
<script id="template-alt" type="text/x-kendo-template">
<div class="alt-color">#:value#</div>
</script>
How can I do this smarter?
Thanks in advance.
/Morten
I initialize a list view in the ini handler of a bootbox.dialog (http://bootboxjs.com/examples.html) from a button in a grid:
$("#listview").kendoListView({...
The content of the dataSource is different from each grid row.
This initialization happen every time the button is clicked.
Can/Should I initialize only once and just update the dataSource.
Thanks in advance
Regards
Morten