ASP.NET MVC Controls | ComponentOne
Working with Controls / FlexGrid / Work with FlexGrid / Header Focusability
In This Topic
    Header Focusability
    In This Topic

    FlexGrid provides a way to access the column headers using the keyboard keys. It gives you the ability to use keyboard arrow keys to move up into or over row and column headers. FlexGrid provides the HeadersFocusability property that determines whether the row and column headers are focusable. To do so, it uses the HeadersFocusability enumeration which specifies the following constants that define the focusability of row and column headers.

    Additionally, once the column headers have focus, the Enter key can be used to trigger a click, performing a sort operation when sorting is enabled on the column.

    Focusable rows and columns in FlexGrid

    The following code showcases how to use HeadersFocusability property which enables you to select the column header and perform sorting on FlexGrid by just using keyboard keys.

    Controller Code

    C#
    Copy Code
    public ActionResult Index(FormCollection collection)
    {
        IValueProvider data = collection;
        var model = Sale.GetData(15);
        return View(model);
    }
    

    View Code

    Index.cshtml
    Copy Code
    @using C1.Web.Mvc.Grid
    @using ApplicationName.Models
    
    @model IEnumerable<Sale>
    
    @(Html.C1().FlexGrid<Sale>()
               .Id("ovFlexGrid")
               .AutoGenerateColumns(true)
               .CssClass("grid")
               .IsReadOnly(true)
               .Bind(bl => bl.Bind(Model))
               .HeadersFocusability(HeadersFocusability.Column)
               .Width("900px"))