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 datasource, which was configured in the application in the Quick Start:
The following code example demonstrates how to manage current records in FlexGrid through CollectionView.
CurrentRecordManagementController.cs
C# |
Copy Code
|
---|---|
private C1NWindEntities db = new C1NWindEntities(); public ActionResult Index() { return View(db); } |
CurrentRecordManagement.cshtml