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

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

1 Answer 12 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Seth
Top achievements
Rank 1
Seth asked on 04 Nov 2016, 03:55 PM

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?

1 Answer, 1 is accepted

Sort by
0
Danail Vasilev
Telerik team
answered on 07 Nov 2016, 11:53 AM
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.
 
Tags
Grid
Asked by
Seth
Top achievements
Rank 1
Answers by
Danail Vasilev
Telerik team
Share this question
or