Selection and Focus

You can use the 'wj-state-focused' pseudo-class to improve accessibility of your FlexGrid controls.

For example, the grid below shows the selection in grey when it does not contain the focus, and adds an orange outline to the selected cell when the grid does have the focus.

Id
Country
Product
Active
Downloads
Sales
Expenses
Overdue
0
US
Phones
145,248
81,732.54
38,401.13
1
Germany
Computers
111,632
20,603.32
27,944.24
2
UK
Cameras
181,205
44,217.79
48,877.49
3
Japan
Stereos
54,740
29,190.63
23,365.74
4
Italy
Phones
126,531
46,951.19
49,107.56
5
Greece
Computers
6,073
86,237.02
49,767.35
1
2
3
4
5
// This file locates: "Scripts/Lesson/C1FlexGrid/SelectionFocus.js".
c1.documentReady(function () {
    var theGrid = wijmo.Control.getControl('#theGrid');
 
});
1
2
3
4
5
6
7
8
9
10
11
// This file locates: "Content/css/Lesson/C1FlexGrid/SelectionFocus.css".
/* de-emphasize selected cells when the grid doesn't contain the focus */
.wj-flexgrid:not(.wj-state-focused) .wj-state-selected,
.wj-flexgrid:not(.wj-state-focused) .wj-state-multi-selected {
  background: #ddd;
}
 
.wj-flexgrid.wj-state-focused .wj-cell.wj-state-selected {
    border: 2px solid orange;
  transition: all 100ms;
}
1
2
3
4
5
6
7
8
9
10
11
12
13
using System.Web.Mvc;
 
namespace LearnMvcClient.Controllers
{
    public partial class C1FlexGridController : Controller
    {
        // GET: SelectionFocus
        public ActionResult SelectionFocus()
        {
            return View(Models.FlexGridData.GetSales());
        }
    }
}
1
2
3
4
5
6
7
8
9
10
11
12
@model IEnumerable<FlexGridData.Sale>
 
<h1>
    @Html.Raw(Resources.C1FlexGrid.SelectionFocus_Title)
</h1>
<p>
    @Html.Raw(Resources.C1FlexGrid.SelectionFocus_Text1)
</p>
<p>
    @Html.Raw(Resources.C1FlexGrid.SelectionFocus_Text2)
</p>
@Html.C1().FlexGrid().Id("theGrid").ShowAlternatingRows(false).Bind(Model)