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

Angular column template function

3 Answers 864 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Tim
Top achievements
Rank 1
Tim asked on 20 Aug 2014, 03:08 PM
I have the need to generate custom HTML by converting each data item returned for a given column when using Angular MVVM.

It seems that I can get the function called when it exists in the controller scope, but the HTML I return doesn't seem to be formatted in the column it just treats it as plain text.

{ "field": "note",
"title": "Notes",
width: "60%",
template: "<span ng-bind=formatNote(dataItem.note)>#= data.note# </span>"
}

$scope.formatNote = function(data) {
        return data.replace(/ /g,"<p>");
};

3 Answers, 1 is accepted

Sort by
0
Petur Subev
Telerik team
answered on 22 Aug 2014, 10:53 AM
Hello Tim,

I am not sure what exactly you are trying to achieve. Inside the template you have multiple ways to format your column - you can use either angular template expressions such as {{ }} and kendo expressions such as #= #.

http://dojo.telerik.com/@pesho/iMASa

Also you can use external function from the controller scope like so:

http://dojo.telerik.com/@pesho/iMASa/2

Combining kendo templates + angular templates should give you all the possible freedom.

===

Update: Here is a similar example with a 2016 version of Kendo UI 


http://dojo.telerik.com/AtURa


Kind Regards,
Petur Subev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Nelson
Top achievements
Rank 1
answered on 02 May 2016, 09:06 PM

Petur, 

When an Angular template expression is used inside the column template, does it allow you to utilize the PDF export still? 

When I export to PDF the column is showing the literal string for the template. {{ dataItem.FirstName }}

0
Nikolay Rusev
Telerik team
answered on 04 May 2016, 08:38 AM

Hello Nelson,

It seems to be working in this example - http://dojo.telerik.com/@rusev/IrULE

Am I missing something here?

Regards,
Nikolay Rusev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
Grid
Asked by
Tim
Top achievements
Rank 1
Answers by
Petur Subev
Telerik team
Nelson
Top achievements
Rank 1
Nikolay Rusev
Telerik team
Share this question
or