Using a MVC Helper how would I lock(freeze) all command columns?

2 posts, 0 answers
  1. Seth
    Seth avatar
    3 posts
    Member since:
    May 2016

    Posted 04 Nov 2016 Link to this post

    We are using a helper for our grid throughout our application.  We are using Gridbuilder<T>.  How would I go about making all grids that use this helper have locked(frozen) command columns?

  2. Danail Vasilev
    Admin
    Danail Vasilev avatar
    1502 posts

    Posted 07 Nov 2016 Link to this post

    Hi Seth,

    I have already replied to the support ticket that was opened by you on this regards and I paste my answer below for the rest of the community:

    Yes, it is possible.  You can find below a modified version of the Grid / Frozen columns demo:

    KendoExtensions.cs:

    Copy Code
    using Kendo.Mvc.UI.Fluent;
     
    namespace KendoCustomFilter.Views
    {
        public static class KendoExtensions
        {
            public static GridBuilder<T> GridFrozenCommandBuilder<T>(thisGridBuilder<T> instance, string name) where T : class
            {
                instance = instance
                    .Name(name)
                        .Columns(columns =>
                        {
                            columns.Command(command => command.Custom("myCommand")).Locked(true).Width(180);
                        });
     
                return instance;
            }
        }
    }


    frozen_columns.cshtml:

    Copy Code
    @using KendoCustomFilter.Views;
    @(Html.Kendo().Grid<Kendo.Mvc.Examples.Models.Order>()
        .GridFrozenCommandBuilder("grid1")
        .Columns(columns =>
        {
            columns.Bound(o => o.OrderID).Width(150).Locked(true).Lockable(false);
            columns.Bound(o => o.ShipCountry).Width(300);
            columns.Bound(o => o.ShipCity).Width(300);
            columns.Bound(o => o.ShipName).Width(300).Locked(true);
            columns.Bound(o => o.ShipAddress).Width(400).Lockable(false);
        })
        .DataSource(dataSource => dataSource
            .Ajax()
            .PageSize(30)
            .Read(read => read.Action("FrozenColumns_Read", "Grid"))
         )
        .Scrollable(scrollable => scrollable.Height(540))
        .Reorderable(reorderable => reorderable.Columns(true))
        .Resizable(resizable => resizable.Columns(true))
        .Pageable()
        .Filterable()
        .Sortable()
        .Groupable()
        .ColumnMenu()
    )
     
    @(Html.Kendo().Grid<Kendo.Mvc.Examples.Models.Order>()
        .GridFrozenCommandBuilder("grid2")
        .Columns(columns =>
        {
            columns.Bound(o => o.OrderID).Width(150).Locked(true).Lockable(false);
            columns.Bound(o => o.ShipCountry).Width(300);
        })
        .DataSource(dataSource => dataSource
            .Ajax()
            .PageSize(30)
            .Read(read => read.Action("FrozenColumns_Read", "Grid"))
         )
        .Scrollable(scrollable => scrollable.Height(540))
        .Reorderable(reorderable => reorderable.Columns(true))
        .Resizable(resizable => resizable.Columns(true))
        .Pageable()
        .Filterable()
        .Sortable()
        .Groupable()
        .ColumnMenu()
    )


    Regards,
    Danail Vasilev
    Telerik by Progress
     
    Build rich, delightful, *native* Angular 2 apps with Kendo UI for Angular 2. Try it out today! Kendo UI for Angular 2 (currently in beta) is a jQuery-free toolset, written in TypeScript, designed from the ground up to offer true, native Angular 2 components.
     
Back to Top