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

[Solved] Conditional bound column

4 Answers 93 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.
Tomer
Top achievements
Rank 1
Tomer asked on 30 Jul 2012, 09:17 AM
Hi,

I am trying to add conditional to bound column on GRID. I saw an example that you showed on conditional column in the past and it didn't help me. In my code It only entered to one conditional only. 
It is Boolean column. for example If I have two rows with one value that is: true and the other is false, I will get to true and It will not entered into the else condition.

Here is my code:

@(Html.Telerik().Grid<CRC.Models.CRC_DB_IsConnected>()

                            .Name("Grid")

                            .Columns(columns =>

                                {

                                    columns.Bound(o => o.Name).Width(200);

                                    columns.Bound(o => o.IsConnected).Width(200);

                                    columns.Bound(o => o.IsConnected).ClientTemplate("<# if( item.IsConnected == true) { #> <img width='16' height='16' alt='Connected' src='" + Url.Content("~/Content/Images/buttonCircle_blank_green.png") + "' /> <# } else {#> <img width='16' height='16' alt='Not Connected' src='" + Url.Content("~/Content/Images/buttonCircle_blank_red.png") + "' /> <# } #>").Title("Is Connected");                                   

                                   

                                })

                                .DataBinding(dataBinding => dataBinding.Ajax().Select("_AjaxBinding""Home"))

                                    .Pageable()

                                    .Sortable()

                                    .Scrollable()

                                    .Groupable()

                                    .Filterable()

                                    )

4 Answers, 1 is accepted

Sort by
0
Dimo
Telerik team
answered on 30 Jul 2012, 11:24 AM
Hi Tomer,

The field names are not used correctly. Please refer to the following forum post and demo:

http://www.telerik.com/community/forums/aspnet-mvc/grid/show-thumbnail-only-if-image-path-is-not-null.aspx#1598178

http://demos.telerik.com/aspnet-mvc/grid/templatesclientside

Greetings,
Dimo
the Telerik team
Check out the successor of Telerik MVC Extensions - Kendo UI for ASP.NET MVC - and deem it for new ASP.NET MVC development.
0
Tomer
Top achievements
Rank 1
answered on 30 Jul 2012, 01:24 PM
Hi,

Can you please explain me why the field names are not used correctly. I tried to understand from the posts that you added and I didn't understand my mistake.

10X.
0
Dimo
Telerik team
answered on 30 Jul 2012, 03:41 PM
Hi Tomer,

The field names in the client template should be used directly - e.g. IsConnected, and not with a parent object (item.IsConnected).

Kind regards,
Dimo
the Telerik team
Check out the successor of Telerik MVC Extensions - Kendo UI for ASP.NET MVC - and deem it for new ASP.NET MVC development.
0
Tomer
Top achievements
Rank 1
answered on 30 Jul 2012, 04:25 PM
10X.

 It works!
Tags
Grid
Asked by
Tomer
Top achievements
Rank 1
Answers by
Dimo
Telerik team
Tomer
Top achievements
Rank 1
Share this question
or