MVC Razor - add condition in toolbar template

2 posts, 0 answers
  1. Jonathan
    Jonathan avatar
    2 posts
    Member since:
    Apr 2013

    Posted 18 Apr 2013 Link to this post

    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,
  2. Vladimir Iliev
    Admin
    Vladimir Iliev avatar
    2194 posts

    Posted 19 Apr 2013 Link to this post

    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!
Back to Top