ComponentOne
Web API Explorer ASP.NET Web API Explorer

MVCFlexGrid

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
using System.Collections.Generic;
using System.Web.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 ActionResult Paging(FormCollection data)
        {
            ViewBag.Options = _flexGridPagingModel;
            _gridPagingModel.LoadPostData(data);
            ViewBag.DemoOptions = _gridPagingModel;
            return View(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
@using WebApiExplorer.Models
@model IEnumerable<Sale>
@{
    GridExportImportOptions exportOptionsModel = ViewBag.Options;
    ControlOptions optionsModel = ViewBag.DemoOptions;
    ViewBag.DemoSettings = true;
}
 
@(Html.C1().FlexGrid<Sale>().Id(exportOptionsModel.ControlId).Height(300)
    .Bind(Model)
    .IsReadOnly(true)
    .PageSize(Convert.ToInt32(optionsModel.Options["PageSize"].CurrentValue))
)
@(Html.C1().Pager().Owner(exportOptionsModel.ControlId))
 
@section Settings{
    @Html.Partial("_OptionsMenu", optionsModel)
    @Html.Partial("_FlexGridOptions", exportOptionsModel)
}
 
@section Description{
    <p>@Html.Raw(Resources.MVCFlexGrid.Paging_Text0)</p>
}