@model Telerik.Web.Mvc.GridModel<MeasureDimensionModel>
@using Telerik.Web.Mvc.UI;
@using System.Linq;
<div class="section-header">
    <div class="title">
        <img src="@Url.Content("~/Administration/Content/images/ico-content.png")" alt="" />
        @T("Admin.Configuration.Measures.Dimensions")
    </div>
</div>
<table class="adminContent">
    <tr>
        <td>
            <b>NOTE: if you change your primary dimension, then do not forget to update the appropriate
                ratios of the units</b>
        </td>
    </tr>
    <tr>
        <td>
            @(Html.Telerik().Grid(Model.Data)
                    .Name("measuredimension-grid")
                    .DataKeys(x =>
                    {
                        x.Add(y => y.Id).RouteKey("Id");
                    })
                    .Columns(columns =>
                    {
                        columns.Bound(x => x.Name).Width(200);
                        columns.Bound(x => x.SystemKeyword).Width(200);
                        columns.Bound(x => x.Ratio).Width(100);
                        columns.Bound(x => x.DisplayOrder).Width(100);
                        columns.Bound(x => x.IsPrimaryDimension).Width(100)
                            .Template(x => x.IsPrimaryDimension.ToString().ToLower()).ReadOnly();
                        columns.Command(commands => commands.Select()).Title("Mark as primary dimension").Width(100);
                        columns.Command(commands =>
                        {
                            commands.Edit();
                            commands.Delete();
                        }).Width(180);

                    })
                    .ToolBar(x => x.Insert())
                    .Editable(x =>
                    {
                        x.Mode(GridEditMode.InLine);
                    })
                    .DataBinding(dataBinding =>
                    {
                        dataBinding.Ajax().Select("Dimensions", "Measure")
                            .Update("DimensionUpdate", "Measure")
                            .Delete("DimensionDelete", "Measure")
                            .Insert("DimensionAdd", "Measure");
                    })
                    .EnableCustomBinding(true))
        </td>
    </tr>
</table>
