This is a migrated thread and some comments may be shown as answers.

Delete Option in Header

2 Answers 34 Views
DropDownList
This is a migrated thread and some comments may be shown as answers.
Marc
Top achievements
Rank 1
Marc asked on 05 Jan 2017, 01:38 PM

I'm trying to add a delete option in the header of the dropdownlist.

 

$scope.layoutOptions = {

 headerTemplate: '<div data-ng-if="selectedLayout.id < 0" class="dropdown-header k-widget k-header"><a href="" data-ng-click="deleteLayout(instance)">Delete    {{selectedLayout.description}}?</a></div>'

}

This are my options (inside an AngularJs controller). Is there any way to pass the selected value (dataItem) to my function deleteLayout?

2 Answers, 1 is accepted

Sort by
0
Accepted
Georgi Krustev
Telerik team
answered on 09 Jan 2017, 09:43 AM
Hello Marc,

As the widget's header is static, it doesn't have any knowledge which item is focused/selected and the moment of button click. The best solution in this case will be to get the selected item from the widget using its API:

$scope.deleteLayout = function() {
  //$scope.ddl is a reference to the Kendo UI DropDownList
 
  var selectedDataItem = $scope.ddl.dataItem(); //use it to delete the same instance from the datasource
}

Regards,
Georgi Krustev
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Marc
Top achievements
Rank 1
answered on 09 Jan 2017, 10:17 AM

Hi Georgi,

This is exactly what I was looking for! Thanks!

Marc

Tags
DropDownList
Asked by
Marc
Top achievements
Rank 1
Answers by
Georgi Krustev
Telerik team
Marc
Top achievements
Rank 1
Share this question
or