FlexGrid
Right To Left
Features
Right To Left
Description
Some languages (Arabic and Hebrew especially) render content from the right to the left of the page. HTML accommodates this with the 'dir' attribute. Setting 'dir' to 'rtl' on any element causes the element's content to flow from right to left.
The FlexGrid supports this automatically. If the element hosting the grid has the 'dir' attribute set to 'rtl', the grid will render columns from the right to the left. You don't have to set any properties on the control.
Note that the 'dir' attribute value is inherited, so if you set it on the body tag for example, the entire page will be rendered from right to left, including the grid.
Note also that CSS has a 'direction' attribute that performs the same function as the 'dir' element attribute. The 'dir' attribute is generally considered more appropriate for several reasons, including the fact that the 'dir' attribute can be used in CSS rules.
using MvcExplorer.Models; using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; namespace MvcExplorer.Controllers { public partial class FlexGridController : Controller { // // GET: /RTL/ public ActionResult RightToLeft() { return View(Sale.GetData(500)); } } }
@model IEnumerable<Sale> <h3> @Html.Raw(Resources.FlexGrid.RightToLeft_RightToLeft)</h3> @(Html.C1().FlexGrid<Sale>() .AutoGenerateColumns(false) .Bind(bl => bl.Bind(Model)) .IsReadOnly(true) .CssClass("grid") .Columns(bl => { bl.Add(cb => cb.Binding("ID")); bl.Add(cb => cb.Binding("Start")); bl.Add(cb => cb.Binding("End")); bl.Add(cb => cb.Binding("Country")); bl.Add(cb => cb.Binding("Product")); bl.Add(cb => cb.Binding("Active")); }) .HtmlAttribute("dir", "rtl") ) @section Description{ <p>@Html.Raw(Resources.FlexGrid.RightToLeft_Text0)</p> <p>@Html.Raw(Resources.FlexGrid.RightToLeft_Text1)</p> <p>@Html.Raw(Resources.FlexGrid.RightToLeft_Text2)</p> <p>@Html.Raw(Resources.FlexGrid.RightToLeft_Text3)</p> }