FlexGrid

FlexGrid allows you to visualize and edit tabular data. It provides a variety of options about how to present and perform operations over the data, including selection, sorting, filtering, grouping, paging, editing, formatting, etc.

Populate the FlexGrid by setting its itemsSource property to an array containing regular JavaScript objects. The grid will automatically generate columns to display the data items, and will allow users to select, sort, and edit the data.

You can customize the grid columns by setting the autoGenerateColumns property to false and populating the columns property in code.

You can customize the default features of grid by setting the properties such as selectionMode, allowSorting, allowDragging, isReadOnly and headersVisibility.

// This file locates: "Scripts/Lesson/C1FlexGrid/Index.js".
c1.documentReady(function () {
    // create some random data
    var countries = 'US,Germany,UK,Japan,Italy,Greece'.split(','),
      data = [];
    for (var i = 0; i < 200; i++) {
        data.push({
            id: i,
            country: countries[i % countries.length],
            active: i % 5 != 0,
            downloads: Math.round(Math.random() * 200000),
            sales: Math.random() * 100000,
            expenses: Math.random() * 50000
        });
    }

    // default grid
    var gridDefault = wijmo.Control.getControl('#gridDefault');
    gridDefault.itemsSource = data;

    // customize columns
    var gridCols = wijmo.Control.getControl('#gridCols');
    gridCols.initialize({
        autoGenerateColumns: false,
        itemsSource: data,
        columns: [
            { header: 'Country', binding: 'country', width: '*' },
            { header: 'Downloads (k)', binding: 'downloads', format: 'n1,' },
            { header: 'Sales (k)', binding: 'sales', format: 'n1,' },
            { header: 'Expenses (k)', binding: 'expenses', format: 'c1,' },
        ]
    });

    // customize properties
    var gridProps = wijmo.Control.getControl('#gridProps');
    gridProps.itemsSource = data;

    var selectionMode = wijmo.Control.getControl('#selectionMode');
    selectionMode.selectedIndexChanged.addHandler(function () {
        gridProps.selectionMode = selectionMode.text
    });
    var allowSorting = wijmo.Control.getControl('#allowSorting');
    allowSorting.selectedIndexChanged.addHandler(function () {
        gridProps.allowSorting = allowSorting.text == 'True';
    });
    var allowDragging = wijmo.Control.getControl('#allowDragging');
    allowDragging.selectedIndexChanged.addHandler(function () {
        gridProps.allowDragging = allowDragging.text;
    });
    var isReadOnly = wijmo.Control.getControl('#isReadOnly');
    isReadOnly.selectedIndexChanged.addHandler(function () {
        gridProps.isReadOnly = isReadOnly.text == 'True';
    });
    var headersVisibility = wijmo.Control.getControl('#headersVisibility');
    headersVisibility.selectedIndexChanged.addHandler(function () {
        gridProps.headersVisibility = headersVisibility.text;
    });
});
// This file locates: "Content/css/Lesson/C1FlexGrid/Index.css".
.wj-flexgrid {
  max-height: 250px;
  margin-bottom: 12px;
}
.header {
  display: inline-block;
  width: 150px;
  text-align: right;
  font-weight: normal;
}
using System.Web.Mvc;

namespace LearnMvcClient.Controllers
{
    public partial class C1FlexGridController : Controller
    {
        // GET: Index
        public ActionResult Index()
        {
            return View();
        }
    }
}
<h1>
    FlexGrid
</h1>
<p>
    FlexGrid allows you to visualize and edit tabular data.
    It provides a variety of options about how to present and
    perform operations over the data, including selection,
    sorting, filtering, grouping, paging, editing, formatting,
    etc.
</p>
<p>
    Populate the FlexGrid by setting its <b>itemsSource</b>
    property to an array containing regular JavaScript objects.
    The grid will automatically generate columns to display
    the data items, and will allow users to select, sort, and
    edit the data.
</p>
@Html.C1().FlexGrid().Id("gridDefault")

<p>
    You can customize the grid columns by setting the
    <b>autoGenerateColumns</b> property to false and populating
    the columns property in code.
</p>
@Html.C1().FlexGrid().Id("gridCols")

<p>
    You can customize the default features of grid by setting
    the properties such as <b>selectionMode</b>, <b>allowSorting</b>, 
    <b>allowDragging</b>, <b>isReadOnly</b> and <b>headersVisibility</b>. 
</p>
@Html.C1().FlexGrid().Id("gridProps")
<label>
    <div class="header">selectionMode:</div>
    @(Html.C1().ComboBox().Id("selectionMode")
        .Bind(new[] { "None", "Cell", "CellRange", "Row", "RowRange", "ListBox" })
        .Text("CellRange")
    )
</label>
<label>
    <div class="header">allowSorting:</div>
    @(Html.C1().ComboBox().Id("allowSorting")
        .Bind(new[] { "True", "False" })
        .Text("True")
    )
</label>
<label>
    <div class="header">allowDragging:</div>
    @(Html.C1().ComboBox().Id("allowDragging")
        .Bind(new[] { "None", "Columns", "Rows", "Both" })
        .Text("Solumns")
    )
</label>
<label>
    <div class="header">isReadOnly:</div>
    @(Html.C1().ComboBox().Id("isReadOnly")
        .Bind(new[] { "True", "False" })
        .Text("False")
    )
</label>
<label>
    <div class="header">headersVisibility:</div>
    @(Html.C1().ComboBox().Id("headersVisibility")
        .Bind(new[] { "None", "Column", "Row", "All" })
        .Text("All")
    )
</label>