I'm trying to create an editor for a HierarchicalDataSource (remotely loaded as JSON).
I'm using `kendo.bind($('#target'),kendo.observable({data: new kendo.data.HierarchicalDataSource(<..config...>)});` to bind a hierarchical datasource with 3 levels of depth (customer -> location -> stores) [as an example]. For each level, I have a separate template for each type of child. I have a dojo demonstrating a static version.
I have several issues:
In a non-MVVM enviroment, I can define the child entities of my hierarchical datasource by setting the schema:
var
datasource =
new
kendo.data.HierarchicalDataSource({
data: [
/*... */
],
schema: {
model: {
children:
"Assets"
}
}
});
In a viewModel I am defining the same datasource like this:
function
buildDataSource(data) {
_.map(data.assets,
function
(item) {
item.type =
"folder"
;
});
var
tree = unflatten(data.assets);
return
tree;
}
function
loadTreeView(dataSource) {
documentsModel.set(
"treeviewSource"
, kendo.observableHierarchy(dataSource));
kendo.bind($(
"#Treeview"
), documentsModel);
}
$.ajax({
dataType:
"json"
,
url:
"scripts/assets.json"
})
.then(buildDataSource)
.then(loadTreeView);
What is happening here, that I am loading a flat array of json objects from a file (later api endpoint) and unflatten this list, so it is in a hierachical format. The method to unflatten this array is naming the children "Assets". Running this, the treeview fails to display. If I change the unflatten method to name those children "items", the treebiew works.
You can reproduce this in this Dojo: http://dojo.telerik.com/UTOBe/3
Change items, to anything else and it stops working. How can I configure the kendo.observableHierarchy, so it uses any other property then "items" to determine if an object has children using a viewModel?
Hello,
I wanted to update my TreeView control which uses a HierarchicalDataSource after I updated the array it uses.
You can see the fiddle here: https://jsfiddle.net/ZoolWay/gev9zj4j/
How can I update/refresh my TreeView after adding items? Changing a text works this way...
// how the datasource is configured:
var
myData = ...
// already contains two items, one with subitems
var
myDataSource =
new
kendo.data.HierarchicalDataSource({
data: myData
});
// add item to the array:
myData.push({
'id'
: 3,
'text'
:
'Item 3'
});
// read the updated array
myDataSource.read();
Currently i am using kendo ui hierarchical . I try to passing ID through url but its not working .
The the problem will solve if can get value from filter .
How do i get value from filter which looking
filter[filters][0][Value_ID]:1472.
Hi,
I am using ASP.NET Web API Odata as server side code to render kendo treeview using hierarchical datasource upto child node level 5. This is really very slow. Now, I need to take it up to level 10. Can you suggest any other solution, apart from Odata, where I can go upto level 10?
Hi,
I'm trying to append an "opened" class to the k-master-row tr when it's clicked and remove it when it's closed so I can do some css styling to the nested grid's parent row. Is there a way to fire a javascript function when you expand or collapse a hierarchical grid or an easier way to do this?
001.
var
people =
new
kendo.data.DataSource({
002.
data: {!Output},
003.
batch:
true
,
004.
schema: {
005.
model: {
006.
fields: {
007.
carId: { type:
"string"
},
008.
vehicleId: { type:
"string"
, editable:
false
},
009.
Percentage: { type:
"number"
, editable:
false
},
010.
Price: { type:
"string"
, editable:
false
},
011.
CarType: { type:
"string"
, editable:
false
},
012.
CarSize: { type:
"string"
, editable:
false
},
013.
CarPerCase: { type:
"number"
, editable:
false
},
014.
Family: { type:
"string"
, editable:
false
},
015.
ModelType: { type:
"string"
, editable:
false
},
016.
EPId: { type:
"string"
},
017.
Tax: { type:
"string"
}
018.
}
019.
}
020.
},
021.
pageSize: 20,
022.
sort: { field:
"vehicleId"
, dir:
"asc"
}
023.
});
024.
var
element = $(
"#grid"
).kendoGrid({
025.
dataSource: people,
026.
navigatable:
true
,
027.
pageable:
true
,
028.
toolbar: [
029.
"save"
,
030.
"cancel"
,
031.
{
032.
name:
"Add"
,
033.
text:
"Show Car Price"
,
034.
click:
function
(e) {
035.
return
false
;
036.
}
037.
},
038.
{
039.
name:
"Delete"
,
040.
text:
"Hide Car Price"
,
041.
click:
function
(e) {
042.
return
false
;
043.
}
044.
}
045.
],
046.
columns:[
047.
{
048.
field:
"carId"
,
049.
title:
"Car ID"
,
050.
width: 150,
051.
hidden:
true
052.
},
053.
{
054.
field:
"vehicleId"
,
055.
title:
"Vehicle ID"
,
056.
width: 100
057.
},
058.
{
059.
field:
"Percentage"
,
060.
title:
"Percentage"
,
061.
width: 70
062.
},
063.
{
064.
field:
"Price"
,
065.
title:
"Price"
,
066.
width: 250
067.
},
068.
{
069.
field:
"CarType"
,
070.
title:
"Car Type"
071.
},
072.
{
073.
field:
"CarSize"
,
074.
title:
"Car Size"
075.
},
076.
{
077.
field:
"CarPerCase"
,
078.
title:
"Car Per Case"
079.
},
080.
{
081.
field:
"Family"
,
082.
title:
"Family"
083.
},
084.
{
085.
field:
"ModelType"
,
086.
title:
"Model Type"
,
087.
width: 100
088.
},
089.
{
090.
field:
"EPId"
,
091.
title:
"EP Id"
,
092.
hidden:
false
093.
},
094.
{
095.
field:
"Tax"
,
096.
title:
"Tax"
,
097.
format:
"{0:c}"
,
098.
width: 100
099.
}
100.
],
101.
editable:
true
,
102.
groupable:
true
,
103.
filterable:
true
,
104.
sortable:
true
,
105.
reorderable:
true
,
106.
resizable:
true
,
107.
columnMenu:
true
,
108.
pageable: {
109.
refresh:
true
,
110.
pageSizes: [10, 20, 50],
111.
buttonCount: 5
112.
},
113.
editable:
"incell"
,
114.
detailInit: detailInit
115.
});
116.
// hierarchy grid
117.
function
detailInit(e) {
118.
var
detailRow = e.detailRow;
119.
codeDetailData = e.data;
120.
121.
$(
"<div/>"
).appendTo(e.detailCell).kendoGrid({
122.
dataSource: e.data.ItemPrices.toJSON(),
123.
editable:
true
,
124.
navigatable:
true
,
125.
scrollable:
false
,
126.
sortable:
true
,
127.
pageable:
true
,
128.
columns: [
129.
{
130.
field:
"Engine"
,
131.
width:
"200px"
,
132.
editor: serviceItemAutoCompleteEditor
133.
},
134.
{
135.
field:
"TN"
,
136.
title:
"TN"
,
137.
width:
"110px"
138.
},
139.
{
140.
field:
"TaxApplied"
,
141.
title:
"Tax Applied"
142.
},
143.
{
144.
field:
"TaxChange"
,
145.
title:
"Tax Change"
,
146.
width:
"300px"
147.
},
148.
{
149.
field:
"StartDate"
,
150.
title:
"Start Date"
,
151.
format:
"{0:dd-MM-yyyy}"
,
152.
editor: dateTimeEditor
153.
},
154.
{
155.
field:
"EndDate"
,
156.
title:
"End Date"
,
157.
format:
"{0:dd-MM-yyyy}"
,
158.
editor: dateTimeEditor
159.
}
160.
]
161.
});
162.
163.
}
Hi,
I have a complex object like
ID
Name
Dob
EmploymentDetailsObject
EmergencyContactObject
I want to bind this to a Kendo Grid so the ID/Name/Dob/ are the parent row and the EmploymentDetails and EmergencyContact are child rows to this parent
I return a collection of these from an API. I thought I could just bind this collection to the Grid but it doesn't seem to work?
Can I do this? What do I need to do?
Thanks
I have a Hierarchical grid and I'm trying to add a custom editor for pop-up editing. When I add the template to the child grid and click on the "edit" button, i get a invalid template error. If i add that same template to the parent, it works fine.
Here is the error in console:
Uncaught Error: Invalid template:'<div class="row popupForm"> <div class="col-xs-10">
I've attached a screenshot of what my grid looks like.
Here is the code
<PARENT>
@(Html.Kendo().Grid<ParentViewModel>()
.Name("GridAdjax")
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(20)
.Events(events => events.Error("error_handler"))
.Read(read => read.Action("Read", "controller"))
.Model(model =>
{
model.Id(c => c.Id);
})
.ServerOperation(false)
.Events(events => events.Error("error_handler"))
.Events(events => events.RequestEnd("onRequestEnd"))
)
.Columns(columns =>
{
columns.Bound(p => p.CompanyName).Title("Company Name");
columns.Bound(p => p.CompanyDomain).Title("Company Domain");
columns.Bound(p => p.CompanySecurityRole).Title("Security Role");
columns.Bound(p => p.CompanySecurityGroup).Title("Security Group");
})
.ClientDetailTemplateId("template")
.Pageable()
.Sortable()
.Resizable(resize => resize.Columns(true))
.Events(e => e.DataBound("OnDataBound"))
.Deferred()
)
<script id="template" type="text/kendo-tmpl">
@(Html.Kendo().Grid<ChildlViewModel>()
.Name("grid_#=CompanyId#")
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(10)
.Update(update => update.Action("CompanyList_Update", "Administration"))
.Read(read => read.Action("Read", "Child", new { companyId = "#=CompanyId#" }))
.Model(model =>
{
model.Id(c => c.Id);
model.Field(c => c.CompanySoldTo).Editable(true);
model.Field(c => c.CompanyDistributionChannel).Editable(true);
model.Field(c => c.CompanyDivision).Editable(true);
model.Field(c => c.CompanyPlant).Editable(true);
model.Field(c => c.CompanySalesOrg).Editable(true);
})
)
.Columns(columns =>
{
columns.Bound(p => p.CompanySoldTo).Title("Sold To");
columns.Bound(p => p.CompanyDistributionChannel).Title("Dist. Chan.");
columns.Bound(p => p.CompanyPlant).Title("Plant");
columns.Bound(p => p.CompanySalesOrg).Title("Sales Org");
columns.Command(command => { command.Edit(); }).Title(("Edit SAP Info."));
})
.Editable(ed => ed.Mode(GridEditMode.PopUp).TemplateName("Detail"))
.Pageable()
.Sortable()
.ToClientTemplate()
)
</script>
<script>
function dataBound() {
this.expandRow(this.tbody.find("tr.k-master-row").first());
}
</script>