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

set input value in template

1 Answer 609 Views
Templates
This is a migrated thread and some comments may be shown as answers.
Maxi
Top achievements
Rank 1
Maxi asked on 04 Dec 2012, 02:15 PM
Hi,

I have a doubt...

 it's possible use a methdo to get the value inside an input ... i mean:
<script id="ReadOnlyText-template" type="text/x-kendo-template">
    ${name}<input type="text" disabled="disabled" data-bind="value:replaceString(value)"></input>
</script>

instead

<script id="ReadOnlyText-template" type="text/x-kendo-template">
    ${name}<input type="text" disabled="disabled" data-bind="value:value"></input>
</script>
where 

<script type="text/javascript">
    function replaceString(value) {
        if(typeof value == 'number' && value !== undefined) {
            return kendo.toString(value, "n2");
        } else {
            return value;
        }
    }
</script>


thanks

1 Answer, 1 is accepted

Sort by
0
Alexander Valchev
Telerik team
answered on 05 Dec 2012, 01:01 PM
Hi Maxi,

This is not possible, because Kendo MVVM bindings are not JavaScript - you cannot call a function and pass parameter to it. 
If a value from the View-Model requires processing before displaying it in the View a method should be created and used instead.
For more information please check this topic.

Kind regards,
Alexander Valchev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Templates
Asked by
Maxi
Top achievements
Rank 1
Answers by
Alexander Valchev
Telerik team
Share this question
or