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

MVC Razor - add condition in toolbar template

1 Answer 434 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jonathan
Top achievements
Rank 1
Jonathan asked on 18 Apr 2013, 07:06 AM
Hi,

I want to add a condition for the toolbar template as follow:

 .ToolBar(toolbar =>
            {
                toolbar.Template(
                    @{
                        if(centre.AttributeCenterRels.Count < 6) {
                            @<div class="action text-align-right">
                                <a href="~/AttributCentreRel/Create?CentreId=@centre.Id" class="btn"><i class="icon-plus"></i> Create</a>
                            </div>
                        }
                        else{
                            @<div class="action text-align-right">
                                Vous ne pouvez spĂ©cifier que 6 attributs pour un centre.
                            </div>
                        }
                    }
                );
            })

Is this possible?

Regards,

1 Answer, 1 is accepted

Sort by
0
Vladimir Iliev
Telerik team
answered on 19 Apr 2013, 10:09 AM
Hi Jonathan,


 Please check the example below of creating such conditional template:

.ToolBar(toolBar => toolBar.Template(@<text>
    @if(count > 5)
    {
        <a href="javascript: void(0);" class="myClass">Click Here</a>
    }
</text>))

Kind Regards,
Vladimir Iliev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Grid
Asked by
Jonathan
Top achievements
Rank 1
Answers by
Vladimir Iliev
Telerik team
Share this question
or