C1 MVC Services

Service is an object defined to provide additional functionality. Currently, ASP.NET MVC Edition provides following two services:

  1. c1.mvc.collections.RemoteCollectionView
  2. c1.mvc.olap.PivotEngine

The service object can be obtained using c1.getService(serviceId).

The sample shows how to create a RemoteCollectionView service and customize it.

Country
Downloads
Sales
Expenses
US
145,248
81,732.54
38,401.13
Germany
111,632
20,603.32
27,944.24
UK
181,205
44,217.79
48,877.49
Japan
54,740
29,190.63
23,365.74
Italy
126,531
46,951.19
49,107.56
Greece
6,073
86,237.02
49,767.35
US
135,436
31,459.18
40,845.40
Germany
169,610
99,190.22
1,631.26
UK
139,988
52,628.41
46,700.93
Japan
137,524
54,681.54
4,055.50
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
// This file locates: "Scripts/Lesson/C1Mvc/Services.js".
var remoteCollectionView;
 
function movePage(obj) {
    if (!remoteCollectionView) {
        return;
    }
 
    if (obj.name === 'Next') {
        remoteCollectionView.moveToNextPage();
    }else{
        remoteCollectionView.moveToPreviousPage();
    }
}
 
c1.documentReady(function () {
    // get the service with the specified id.
    remoteCollectionView = c1.getService('sCV');
});
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: Services
        public ActionResult Services()
        {
            return View(Models.FlexGridData.GetSales(200));
        }
    }
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
@model IEnumerable<FlexGridData.Sale>
 
<h1>
    @Html.Raw(Resources.C1Mvc.Services_Title)
</h1>
 
<p>
    @Html.Raw(Resources.C1Mvc.Services_Text1)
</p>
<ol>
    <li>
        @Html.Raw(Resources.C1Mvc.Services_Text2)
    </li>
    <li>
        @Html.Raw(Resources.C1Mvc.Services_Text3)
    </li>
</ol>
<p>
    @Html.Raw(Resources.C1Mvc.Services_Text4)
</p>
<p>
    @Html.Raw(Resources.C1Mvc.Services_Text5)
</p>
@Html.C1().CollectionViewService().Id("sCV").Bind(Model).DisableServerRead(true).PageSize(10)
@(Html.C1().FlexGrid().ItemsSourceId("sCV").AutoGenerateColumns(false)
    .Columns(cs=>
    {
        cs.Add().Binding("Country").Header("Country");
        cs.Add().Binding("Downloads").Header("Downloads");
        cs.Add().Binding("Sales").Header("Sales");
        cs.Add().Binding("Expenses").Header("Expenses");
    })
)
<input type="button" value="@Resources.C1Mvc.Services_Text6" name="Previous" onclick="movePage(this)" />
<input type="button" value="@Resources.C1Mvc.Services_Text7" name="Next" onclick="movePage(this)" />