ASP.NET MVC コントロールヘルプ
OData連結
コントロールの使用 > FlexGrid > FlexGridの使用 > データ連結 > OData連結

OData model is a server-side model, so entire data is available at the server side. To apply OData binding in FlexGrid, you need to specify the service url, table name, and keys property. This topic describes how to add data to FlexGrid using OData binding.

The following image shows how the FlexGrid control appears after implementing the code below.

In Code

FlexGridController

C#
コードのコピー
public class FlexGridController : Controller
    {
        // GET: FlexGrid
        public ActionResult Index()
        {
            return View();
        }
    }

Index.cshtml

Razor
コードのコピー
@(Html.C1().FlexGrid()
        .Id("ODataBinding")
        .IsReadOnly(true)
        .AllowAddNew(false)
        .AllowDelete(false)
        .CssStyle("height", "300px")
        .AutoGenerateColumns(false)
        .BindODataSource(odsb =>
                            odsb.ServiceUrl("http://services.odata.org/Northwind/Northwind.svc")
                            .TableName("Products")
                            .Keys("ProductID"))
        .Columns(csb =>
        {
            csb.Add(cb => cb.Binding("ProductID").Width("*"));
            csb.Add(cb => cb.Binding("ProductName").Width("*"));
            csb.Add(cb => cb.Binding("QuantityPerUnit").Width("*"));
            csb.Add(cb => cb.Binding("UnitsInStock").Width("*"));
        })
        .Filterable(fb => fb.DefaultFilterType(FilterType.Both)))