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

[Solved] Template with ajax binding

6 Answers 127 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Julien
Top achievements
Rank 1
Julien asked on 02 Feb 2012, 11:25 AM
Hi,

I want to have ajax binding and template.

I saw that: http://demos.telerik.com/aspnet-mvc/razor/grid/templatesclientside 

But I don't understand the synthax. Why should I use aspx tags since I'm with the razor engine?

Can I have a conditional display(e.g. having date coming in red if the date is already past?)

6 Answers, 1 is accepted

Sort by
0
nachid
Top achievements
Rank 1
answered on 02 Feb 2012, 12:57 PM
I cannot see where you're seeing this aspx tag.
Regarding the conditionnal display, you can use the conditional formatting
However, this last one is available only in server binding mode.
0
Julien
Top achievements
Rank 1
answered on 02 Feb 2012, 01:05 PM
A screenshot showing tags:
http://screencast.com/t/TrMymuavRqu 

Why is this usable only in server binding mode? In server binding mode we can already use conditional formating in template, we don't need this. So how should I do a thing as basic than putting in red some fields on ajax binding mode?
0
Atanas Korchev
Telerik team
answered on 02 Feb 2012, 01:14 PM
Hi,

 Those are not ASPX tags. Those a client-side template expressions which are Telerik specific.

Here is how to make some fields red

columns.Bound(o => o.OrderID).ClientTemplate("<span style='color:red'><#= OrderID #></span>");

Regards,
Atanas Korchev
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the Telerik Extensions for ASP.MET MVC, subscribe to their blog feed now
0
Julien
Top achievements
Rank 1
answered on 02 Feb 2012, 01:19 PM
Ok thank you, do you have a reference somewhere for those tags?

But like this I will have everytime the field in red.

How to have by example your OrderID appearing in red, if it has 0 as value?
0
Atanas Korchev
Telerik team
answered on 02 Feb 2012, 01:28 PM
Hi,

 Here is a link to the documentation. You can make conditional coloring by using a JavaScript function in the template

columns.Bound(o => o.OrderID).ClientTemplate("<#= template(data) #>");


<script>
    function template(dataRow) {
        if (dataRow.OrderID == 0) {
              return "<span style='color:red'>" + dataRow.OrderID + "</span>";
        }

         return "<span style='color:blue'>" + dataRow.OrderID + "</span>"; 
    }
</script>

All the best,
Atanas Korchev
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the Telerik Extensions for ASP.MET MVC, subscribe to their blog feed now
0
nachid
Top achievements
Rank 1
answered on 03 Feb 2012, 07:49 AM
Thank you Atanas,
That's really great and I just discovered we can use a function in the template the way you mentioned.
However, I am wondering from where come this value data
Shouldn't be dataItem only?
Tags
Grid
Asked by
Julien
Top achievements
Rank 1
Answers by
nachid
Top achievements
Rank 1
Julien
Top achievements
Rank 1
Atanas Korchev
Telerik team
Share this question
or