Hi,
I have a list with and edit button, when clicking on the button I have to open the detail and select the row before opening it. After editing, I want to navigate back to the list and see the latest edited item selected.
This is not working (it use to work in previous implementation angular-kendo):
var dataItem = this.dataItem(this.select());
This works, but I'd not like to not using jquery inside a controller:
var dataItem = this.dataItem($(e.currentTarget).closest("tr"));
I'm preserving the last selected item in an outer controller by listening gridOnChange and reset back when gridOnDataBound, something like:
$scope.lastSelectedDataItem = {};
$scope.gridOnChange = function (e) {
var grid = e.sender,
key = grid.dataSource.transport.options.read.url;
$scope.lastSelectedDataItem[key] = grid.dataItem(grid.select());
};
$scope.gridOnDataBound = function (e) {
var grid = e.sender,
key = grid.dataSource.transport.options.read.url,
view = grid.dataSource.view(),
i;
if ($scope.lastSelectedDataItem[key] === undefined) {
return;
}
for (i = 0; i < view.length; i += 1) {
if (view[i].Id === $scope.lastSelectedDataItem[key].Id) {
grid.select(grid.table.find("tr[data-uid='" + view[i].uid + "']"));
break;
}
}
};
The selection is working only if I click on the edit icon on the toolbar, not on the text "Edit".
Enrico
I have a list with and edit button, when clicking on the button I have to open the detail and select the row before opening it. After editing, I want to navigate back to the list and see the latest edited item selected.
This is not working (it use to work in previous implementation angular-kendo):
var dataItem = this.dataItem(this.select());
This works, but I'd not like to not using jquery inside a controller:
var dataItem = this.dataItem($(e.currentTarget).closest("tr"));
I'm preserving the last selected item in an outer controller by listening gridOnChange and reset back when gridOnDataBound, something like:
$scope.lastSelectedDataItem = {};
$scope.gridOnChange = function (e) {
var grid = e.sender,
key = grid.dataSource.transport.options.read.url;
$scope.lastSelectedDataItem[key] = grid.dataItem(grid.select());
};
$scope.gridOnDataBound = function (e) {
var grid = e.sender,
key = grid.dataSource.transport.options.read.url,
view = grid.dataSource.view(),
i;
if ($scope.lastSelectedDataItem[key] === undefined) {
return;
}
for (i = 0; i < view.length; i += 1) {
if (view[i].Id === $scope.lastSelectedDataItem[key].Id) {
grid.select(grid.table.find("tr[data-uid='" + view[i].uid + "']"));
break;
}
}
};
The selection is working only if I click on the edit icon on the toolbar, not on the text "Edit".
Enrico