CollectionView

CollectionView class is the core data provider for our MVC controls. It takes a sourceCollection array and provides data views with sorting, filtering, grouping, paging, notifications, change tracking, currency management, and more.

The views created by the CollectionView are exposed through the items property, which contains an array with sorted/filtered/grouped/paged items from the sourceCollection array.

Controls that have an itemsSource property accept CollectionView objects as well as regular arrays. If regular arrays are used, the control automatically creates an internal CollectionView to wrap the original data. This internal CollectionView is exposed by the control's collectionView property.

The CollectionView class provides extensive functionality and a consistent way for controls to deal with data.

C1 MVC includes classes that extend CollectionView to provide additional services. The best example is ODataCollectionView, which provides access to OData sources.

1
2
3
4
5
6
7
8
9
10
11
12
13
using System.Web.Mvc;
 
namespace LearnMvcClient.Controllers
{
    public partial class C1MvcController : Controller
    {
        // GET: CollectionView
        public ActionResult CollectionView()
        {
            return View();
        }
    }
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
<h1>
    @Html.Raw(Resources.C1Mvc.CollectionView_Title)
</h1>
 
<p>
    @Html.Raw(Resources.C1Mvc.CollectionView_Text1)
</p>
<p>
    @Html.Raw(Resources.C1Mvc.CollectionView_Text2)
</p>
<p>
    @Html.Raw(Resources.C1Mvc.CollectionView_Text3)
</p>
<p>
    @Html.Raw(Resources.C1Mvc.CollectionView_Text4)
</p>
<p style="display:none;">
    @Html.Raw(Resources.C1Mvc.CollectionView_Text5)
</p>