4 Answers, 1 is accepted
0
Hi Kake,
You will still have to find the corresponding item and use the select method, but you can use the following approach:
Please examine the dojo example and see if it meets your requirements.
Regards,
Konstantin Dikov
Telerik
You will still have to find the corresponding item and use the select method, but you can use the following approach:
Please examine the dojo example and see if it meets your requirements.
Regards,
Konstantin Dikov
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Kake
Top achievements
Rank 1
answered on 16 Oct 2015, 08:12 AM
Thanks for the reply.
Not sure where I Fu#% up..
When I do the $scope.tree.findByText(nodeTekst))
it
returns “[]” (have testet multiple strings I know match the tekst(s) in the
nodes )
I try to select the root node if node is selected in
the databound event of the tree.
some code..
<!-- Tree Init -->
<
div
kendo-tree-view
=
"tree"
id
=
"tree"
k-data-source
=
"treeData"
k-options
=
"treeOptions"
>
<
span
k-template>
<
i
class
=
"fa fa-folder-open"
ng-hide
=
"{{!dataItem.expanded}}"
></
i
>
<
i
class
=
"fa fa-folder"
ng-hide
=
"{{dataItem.expanded}}"
></
i
>
{{dataItem.text}}
</
span
>
</
div
>
var
onDatabound =
function
(e) {
if
($.isEmptyObject($scope.selectedNode)) {
debugger;
var
item = $scope.tree.findByText(containerId);
$scope.tree.select(item);
}
};
var
setSelected =
function
(e) {
$scope.selectedNode = e.sender.dataItem(e.node);
$scope.gridOptions.dataSource.data([]);
$scope.gridOptions.dataSource.read();
$scope.$apply();
};
$scope.treeOptions = {
select: setSelected,
dataBound: onDatabound
};
+++
0
Accepted
Hello Kake,
When you are using template, the findByText method will not work, because it relies on the content of the item to find. For finding the correct item and select it you could manually traverse the items collection and using the dataItem, compare the text value:
Hope this resolves the issue on your side too.
Regards,
Konstantin Dikov
Telerik
When you are using template, the findByText method will not work, because it relies on the content of the item to find. For finding the correct item and select it you could manually traverse the items collection and using the dataItem, compare the text value:
$scope.onDatabound =
function
(e) {
if
($.isEmptyObject($scope.selectedNode)) {
var
item;
var
items = e.sender.items();
for
(
var
i = 0; i < items.length; i++) {
if
(e.sender.dataItem(items[i]).text == containerId) {
item = items[i];
break
;
}
}
e.sender.select(item);
}
};
Hope this resolves the issue on your side too.
Regards,
Konstantin Dikov
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Kake
Top achievements
Rank 1
answered on 22 Oct 2015, 08:03 AM
Had to "manually" trigger the selected event, now it works ! (e.sender.trigger( 'select', {node: item} );)
Tnx!