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

Add "ng-click" to item

4 Answers 64 Views
Data Source
This is a migrated thread and some comments may be shown as answers.
Werner Haltner
Top achievements
Rank 1
Werner Haltner asked on 04 Aug 2015, 09:41 AM

Hello

I have a DataSource with Items and i want to add a "ng-click" to each data item, which should trigger the corresponding $scope function.

How can i add a "ng-click" to the items?

 

Thanks,
Werner

 

4 Answers, 1 is accepted

Sort by
0
Werner Haltner
Top achievements
Rank 1
answered on 05 Aug 2015, 06:55 AM

Meanwhile i fix the problem using/bind the "select" Event and call then the needed function.

If there is another solution, i would like to know it.

Thanks,
Werner

 

0
Alexander Popov
Telerik team
answered on 06 Aug 2015, 06:55 AM
Hi Werner,

The ng-click event handler should be attached to specific HTML elements - attaching it directly to DataSource items is not supported. Would you please share more details about your scenario? That will help us suggest a better solution.

Regards,
Alexander Popov
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Werner Haltner
Top achievements
Rank 1
answered on 06 Aug 2015, 07:14 AM

Hello Alexander

Before i use the DataSource i have set a link with "ng-repeat" and each link has a "ng-click" attribute.
Something like this:

<a ui-sref="demo.demoItem({demoPath: nav.Path.Path, demoSystemId:nav.Path.FolderSystemId})" ng-click="events.doSomething(nav.Path.Path)"></a>

 

Then i start using the DataSource and set the link via the URL property. Like this:

{
...
url : "#/demo/demo/" + demoPath + "/" + demo.Path.demoSystemId + "";
...
}

i use then in the panelbar widget the "select" Event and handle the same logic which i had before in the "events.doSomething()" method from "ng-click"

 

So, the question is,
a) is it possible, to set some additional properties, functions in the data item from a dataSource?
b) and how to access this property/function ?

 

Thanks,
Werner

 

 

 

 

 

0
Alexander Popov
Telerik team
answered on 10 Aug 2015, 11:01 AM
Hello Werner,

The PanelBar has no means of correlating its items to the corresponding DataSource records (e.g dataItem method). You could however, try using the index of the selected panel in the event handler, as shown here. If that is not the behavior you are after I would ask you to modify the Dojo accordingly and share more details about what the expected behavior is.

Regards,
Alexander Popov
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
Data Source
Asked by
Werner Haltner
Top achievements
Rank 1
Answers by
Werner Haltner
Top achievements
Rank 1
Alexander Popov
Telerik team
Share this question
or