リモートデータ連結

リモートデータ連結

機能

Settings


エクスポート
エクスポート名:

Description

このサンプルでは、何らかのアクションから取得したデータを含む MVC FlexGrid を Excel ファイルにエクスポートする方法を示します。
using C1.Web.Mvc;
using C1.Web.Mvc.Serialization;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using WebApiExplorer.Models;

namespace WebApiExplorer.Controllers
{
    public partial class MVCFlexGridController : Controller
    {
        private readonly GridExportImportOptions _flexGridRemoteBindModel = new GridExportImportOptions
        {
            NeedExport = true,
            NeedImport = false,
            IncludeColumnHeaders = true
        };


        public IActionResult RemoteBind()
        {
            ViewBag.Options = _flexGridRemoteBindModel;
            return View();
        }

        public IActionResult RemoteBind_Read([C1JsonRequest] CollectionViewRequest<Sale> requestData)
        {
            return this.C1Json(CollectionViewHelper.Read(requestData, Sale.GetData(500)));
        }
    }
}
@{
    GridExportImportOptions optionsModel = ViewBag.Options;
    ViewBag.DemoSettings = true;
}

<c1-flex-grid id="@optionsModel.ControlId" auto-generate-columns="false" sorting-type="MultiColumn" is-read-only="true"
                class="grid" selection-mode="Row">
    <c1-items-source initial-items-count="10" read-action-url="@Url.Action("RemoteBind_Read")"></c1-items-source>
    <c1-flex-grid-column binding="ID" is-visible="false"></c1-flex-grid-column>
    <c1-flex-grid-column binding="Start" format="MMM d yy"></c1-flex-grid-column>
    <c1-flex-grid-column binding="End" format="HH:mm"></c1-flex-grid-column>
    <c1-flex-grid-column binding="Country"></c1-flex-grid-column>
    <c1-flex-grid-column binding="Product"></c1-flex-grid-column>
    <c1-flex-grid-column binding="Color"></c1-flex-grid-column>
    <c1-flex-grid-column binding="Amount" format="c"></c1-flex-grid-column>
    <c1-flex-grid-column binding="Amount2" format="c"></c1-flex-grid-column>
    <c1-flex-grid-column binding="Discount" format="p0"></c1-flex-grid-column>
    <c1-flex-grid-column binding="Active"></c1-flex-grid-column>
</c1-flex-grid>

@section Settings{
    @await Html.PartialAsync("_FlexGridOptions", optionsModel)
}

@section Description{
    @Html.Raw(MVCFlexGrid.RemoteBind_Text0)
}