Working with Controls / CollectionView / Work with CollectionView / Client- Side Operations / Current Record Management
Current Record Management

CollectionView can manage the current record by using the ICollectionView interface.

To obtain the current position of a record in the collection, use currentPosition property. We also use the methods moveCurrentTo(item), moveCurrentToFirst(), moveCurrentToLast(), moveCurrentToNext(), moveCurrentToPosition(index) and moveCurrentToPrevious() to change the current position. When the current is changed, we use the events currentChanging and currentChanged to track it. We can cancel the current changing in the event currentChanging.

Make sure that the DisableServerRead property of ItemSource is set to True if filtering, paging, sorting is to be performed on data available at client side only.

The example uses C1NWind data source, which was configured in the application in the Quick Start:

Record management in FlexGrid

The following code example demonstrates how to manage current records in FlexGrid through CollectionView.

In Code

CurrentRecordManagementController.cs

C#
Copy Code
private C1NWindEntities db = new C1NWindEntities();

public ActionResult Index()
{
    return View(db);
}

CurrentRecordManagement.cshtml

Razor
Copy Code
<div>
    <button class="btn btn-default" id="btnCRMMoveNext">Move To Next</button>
    <button class="btn btn-default" id="btnCRMMovePre">Move To Previous</button>
    <button class="btn btn-default" id="btnCRMStop4">Stop in 4th Row</button>
    <button class="btn btn-default" id="btnCRMReset">Clear Stopping</button>
</div>
@(Html.C1().FlexGrid().Id("crmGrid").IsReadOnly(true).SelectionMode(C1.Web.Mvc.Grid.SelectionMode.Row)
.Height(300).Width(800).AutoGenerateColumns(true).Bind(b => b.DisableServerRead(true).Bind(Model.Customers))
)