Paging

Paging

This sample demonstrates how to export a paged mvc FlexGrid to excel file.

Features

ID
Start
End
Country
Product
Color
Amount
Amount2
Discount
Active
Rank
1
1/25/2025
1/25/2025
German
Gadget
Green
581.61
-2,939.67
0.14
4
2
2/25/2025
2/25/2025
Canada
Gadget
Green
4,919.02
-4,673.75
0.17
2
3
3/25/2025
3/25/2025
Japan
Gadget
Red
2,159.73
-3,810.42
0.07
5
4
4/25/2025
4/25/2025
German
Gadget
Red
1,248.66
-2,815.93
0.22
1
5
5/25/2025
5/25/2025
German
Gadget
Black
4,051.76
-3,108.76
0.12
2
6
6/25/2025
6/25/2025
Canada
Gadget
Black
-3,131.28
-4,314.81
0.16
5
7
7/25/2025
7/25/2025
China
Widget
Red
698.62
-2,745.97
0.15
3
8
8/25/2025
8/25/2025
US
Widget
White
3,464.15
1,131.58
0.03
2
9
9/25/2025
9/25/2025
Korea
Gadget
Black
-2,363.16
3,425.60
0.14
2
10
10/25/2025
10/25/2025
US
Widget
White
-2,836.94
-4,283.10
0.06
1
11
11/25/2025
11/25/2025
France
Widget
Green
877.93
2,722.02
0.08
2
12
12/25/2025
12/25/2025
Korea
Widget
Red
-3,788.14
-3,050.89
0.12
5
13
1/25/2025
1/25/2025
German
Gadget
Red
-2,446.92
-2,351.67
0.12
1
14
2/25/2025
2/25/2025
German
Widget
Black
-4,374.97
-3,899.38
0.18
4
15
3/25/2025
3/25/2025
Japan
Gadget
Green
1,089.32
-4,102.95
0.16
5

Settings


Export
Export Name :

Description

This sample demonstrates how to export a paged mvc FlexGrid to excel file.

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
36
37
38
39
40
41
42
43
44
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using C1.Web.Mvc;
using C1.Web.Mvc.Serialization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using WebApiExplorer.Models;
  
namespace WebApiExplorer.Controllers
{
    public partial class MVCFlexGridController : Controller
    {
        private readonly GridExportImportOptions _flexGridPagingModel = new GridExportImportOptions
        {
            NeedExport = true,
            NeedImport = false,
            OnlyCurrentPage = false,
            IncludeColumnHeaders = true
        };
  
        private readonly ControlOptions _gridPagingModel = new ControlOptions
        {
            Options = new OptionDictionary
            {
                {"Page Size", new OptionItem {Values = new List<string> {"10", "25", "50", "100"}, CurrentValue = "25"}},
            }
        };
  
        public IActionResult Paging(IFormCollection data)
        {
            _gridPagingModel.LoadPostData(data);
            ViewBag.DemoOptions = _gridPagingModel;
            ViewBag.Options = _flexGridPagingModel;
            return View();
        }
  
        public ActionResult Paging_Bind([C1JsonRequest] CollectionViewRequest<Sale> requestData)
        {
            return this.C1Json(CollectionViewHelper.Read(requestData, Sale.GetData(500)));
        }
    }
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
@{
    GridExportImportOptions exportOptionsModel = ViewBag.Options;
    ControlOptions optionsModel = ViewBag.DemoOptions;
    ViewBag.DemoSettings = true;
}
  
<c1-items-source id="collectionViewService" read-action-url="@Url.Action("Paging_Bind")"
                 page-size="@Convert.ToInt32(optionsModel.Options["PageSize"].CurrentValue)"></c1-items-source>
<c1-pager owner="collectionViewService"></c1-pager>
  
<c1-flex-grid height="300px" id="@exportOptionsModel.ControlId" class="customGrid"
              is-read-only="true" items-source-id="collectionViewService">
</c1-flex-grid>
  
<c1-pager owner="@exportOptionsModel.ControlId"></c1-pager>
  
@section Settings{
    @await Html.PartialAsync("_OptionsMenu", optionsModel)
    @await Html.PartialAsync("_FlexGridOptions", exportOptionsModel)
}
  
@section Description{
    <p>@Html.Raw(MVCFlexGrid.Paging_Text0)</p>
}