|
<ej:Grid ID="FlatGrid" runat="server" AllowPaging="true" AllowGrouping="true" AllowFiltering="true" AllowSorting="true" AllowSearching="true">
<DataManager URL="/Default.aspx/DataSource" Adaptor="WebMethodAdaptor" />
<FilterSettings FilterType="Excel" />
<Columns>
<ej:Column Field="OrderID" HeaderText="Order ID" IsPrimaryKey="True" TextAlign="Right" Width="75" />
<ej:Column Field="CustomerID" HeaderText="Customer ID" Width="80" />
<ej:Column Field="EmployeeID" HeaderText="Employee Name" ForeignKeyField="EmployeeID" ForeignKeyValue ="FirstName" TextAlign ="Right" Width="80" />
. . .
</Columns>
</ej:Grid>
</div>
[WebMethod]
protected void Page_Load(object sender, EventArgs e)
{
this.FlatGrid.Columns[2].DataSource = Employee;
this.FlatGrid.DataBind();
BindDataSource();
BindData();
}
public class Employees
{
public int EmployeeID { get; set; }
public string FirstName { get; set; }
public string Country { get; set; }
public int ID { get; set; }
}
public class Orders
{
public long OrderID { get; set; }
public string CustomerID { get; set; }
public int EmployeeID { get; set; }
}
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public static object DataSource(Syncfusion.JavaScript.DataManager value)
{
IEnumerable GridData = order;
IEnumerable empData = Employee;
DataOperations ds = new DataOperations();
if (value.Where != null && value.Where.Count > 0) //Filtering
{
GridData = ds.PerformWhereFilter(GridData, value.Where, value.Where[0].Operator);
}
var count = GridData.Cast<Orders>().Count();
if (value.Skip > 0)
GridData = ds.PerformSkip(GridData, value.Skip);
if(value.Take > 0)
GridData = ds.PerformTake(GridData, value.Take);
return new { result = GridData, count = count };
}
|