<EjsGrid id="Grid" ref="@grid" AllowPaging="true">
<EjsDataManager Url="api/Default" Adaptor="Adaptors.WebApiAdaptor"></EjsDataManager>
<GridColumns>
<GridColumn Field="OrderID" HeaderText="Order ID" ISPrimaryKey="true" TextAlign="@Syncfusion.EJ2.RazorComponents.Grids.TextAlign.Right" Width="90"></GridColumn>
<GridColumn Field="CustomerID" HeaderText="Customer ID" Width="90"></GridColumn>
<GridColumn Field="EmployeeID" HeaderText="Employee ID" Width="90"></GridColumn>
<GridColumn Field="Freight" HeaderText="Freight" Width="90"></GridColumn>
</GridColumns>
</EjsGrid> |
public object Get()
{
BindDataSource();
var data = order.AsQueryable();
var count = order.Count;
var queryString = Request.Query;
if (queryString.Keys.Contains("$inlinecount"))
{
StringValues Skip;
StringValues Take;
int skip = (queryString.TryGetValue("$skip", out Skip)) ? Convert.ToInt32(Skip[0]) : 0;
int top = (queryString.TryGetValue("$top", out Take)) ? Convert.ToInt32(Take[0]) : data.Count();
return new { Items = data.Skip(skip).Take(top), Count = count };
}
else
{
return data;
} |
|
[HttpGet]
public object Get()
{
...
var queryString = Request.Query; //Based on this request query, handle the search/sort action.
string sort = queryString["$orderby"]; //get the sorting query here
string filter = queryString["$filter"]; //get the search query here
...
}
|