@model IEnumerable<FlexGridData.Sale>

<h1>
    CollectionView Validation
</h1>
<p>
    FlexGrid works with the <b>CollectionView</b> class to
    provide item and collection-level validation.
</p>
<p>
    To use this feature, set <b>getError</b> to a function that
    takes two parameters containing the data item being validated
    and the property to validate, and returns a string describing
    the error condition (or null if there are no errors).
</p>
<p>
    The grid below has a data source that implements a <b>getError</b>
    function that ensures the 'Sales' and 'Expenses' properties of the
    items contain positive values. To see how validation works,
    try entering negative values in either column:
</p>
@(Html.C1().FlexGrid().Id("theGrid").Height(200)
    .AutoGenerateColumns(false)
    .Bind(Model)
    .Columns(cs =>
    {
        cs.Add().Binding("Id").Header("ID").Width("50").IsReadOnly(true);
        cs.Add().Binding("Country").Header("Country").IsRequired(true);
        cs.Add().Binding("Sales").Header("Sales").Format("n2");
        cs.Add().Binding("Expenses").Header("Expenses").Format("n2");
        cs.Add().Binding("Overdue").Header("Overdue");
    })
)

<p>
    The grid has two properties that allow you to customize its
    validation behavior:
</p>
<ul>
    <li>
        <b>showErrors:</b>
        Whether the grid should add the 'wj-state-invalid' class
        to cells that contain validation errors, and tooltips
        with error descriptions.
    </li>
    <li>
        <b>validateEdits:</b>
        Whether the grid should remain in edit mode when the user
        tries to commit edits that fail validation
    </li>
</ul>