0
Reply

kendo UI with if statement and swtich

Cassie Mod

Cassie Mod

Mar 22 2016 12:13 PM
384
HI,
 
Ive got the following kendo Grid .  ( see code below). I used a client template for the swtich statement. However I also need to do a check ( if statement). How can I implement the if statement  before the binding of p.HostedTypeString so it has already performed there check.
 
@using Kendo.Mvc.UI
@using OneXS.FrontOffice.ETS.Portal.Models.Types
@using OneXS.Orion.Framework
@using OneXS.Orion.Framework.MVC.Authorisation
@{
ViewBag.Title = GlobalResources.Partitions;
}
<div class="page-header">
<h1>@ViewBag.Title</h1>
</div>
<div class="row">
<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
<div class="hidden bg-danger" id="errorMessage"></div>
@(Html.Kendo().Grid<PartitionGridItem>()
.Name("Grid")
.Columns(columns =>
{
columns.Bound(p => p.PlatformString);
columns.Bound(p => p.ServiceProvider);
columns.Bound(p => p.PartitionName).ClientTemplate("<a href=\"" + Url.Action("Details", "Partition") + "/#=PartitionCode#\">#=PartitionName#</a>");
 
 
// This first needs to be checked ( if hostedTypeString == Compleet OR HostedTypeString ==DeanOneHosted) &&  (s.Finish == null || s.Finish > systemdate.today) // BUT HOW ???? !!!

                 columns.Bound(p => p.HostedTypeString).ClientTemplate("# switch (HostedTypeString) {" +
"case 'Compleet': # Compleet <a class=\"glyphicon glyphicon-new-window\" onclick=\"openManagementCompleet(this); return false;\" data-partitioncode=\"" + "#=PartitionCode#" + "\" />" + "# break;" +
"case 'DeanOneHosted': # onepro <a class=\"glyphicon glyphicon-new-window\" onclick=\"openManagementDeanOne(this); return false;\" data-partitioncode=\"" + "#=PartitionCode#" + "\" />" + "# break;" +
"default: # #=HostedTypeString# #" +
"}#");

columns.Bound(s => s.Start).Format("{0:d}");
columns.Bound(s => s.Finish).Format("{0:d}");
columns.Bound(p => p.Customer);
columns.Bound(p => p.Partner);
columns.Bound(p => p.AccountManager);
columns.Bound(p => p.PartitionId).Hidden();
})
.ToolBar(toolbar =>
{
toolbar.Template(
@<text>
<div class="pull-right">
<select id="selectActive"><option value="null">Alle diensten</option><option selected="selected" value="true">Actieve diensten</option><option value="false">Niet actieve diensten</option></select>
<input type="search" class="k-textbox" id="search" size="30" placeholder="Snel zoeken" />
</div>
</text>
);
})
.Selectable(s => s.Enabled(false))
.Reorderable(r => r.Columns(false))
.Resizable(r => r.Columns(true))
.Scrollable(s => s.Height("auto").Enabled(false))
.Sortable(sortable => sortable
.AllowUnsort(true)
.SortMode(GridSortMode.SingleColumn)
)
.Filterable()
.Pageable()
.DataSource(ds => ds
.Ajax()
.ServerOperation(false)
.Events(events => events.RequestStart("gridEventRequestStart"))
.Events(events => events.Error("gridEventError"))
.Read(read => read.Action("Index", "Partition").Data("getActiveSelection")))
)
</div>
</div>