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.
FlexGridController
C# |
Copy Code
|
---|---|
public class FlexGridController : Controller { // GET: FlexGrid public ActionResult Index() { return View(); } } |
Index.cshtml
HTML |
Copy Code
|
---|---|
<c1-flex-grid is-read-only="true" auto-generate-columns="false" id="ODataBinding" allow-add-new="false" allow-delete="false" style="height:300px"> <c1-flex-grid-column binding="ProductID" width="*"></c1-flex-grid-column> <c1-flex-grid-column binding="ProductName" width="*"></c1-flex-grid-column> <c1-flex-grid-column binding="QuantityPerUnit" width="*"></c1-flex-grid-column> <c1-flex-grid-column binding="UnitsInStock" width="*"></c1-flex-grid-column> <c1-odata-source service-url="https://services.odata.org/Northwind/Northwind.svc" table-name="Products" keys="ProductID"> </c1-odata-source> <c1-flex-grid-filter default-filter-type="Both"></c1-flex-grid-filter> </c1-flex-grid> |