BoldSignEasily embed eSignatures in your .NET applications. Free sandbox with native SDK available.
The DataManager class helps in binding the Grid queries passed to the server-side. Based on those queries you can perform server-side operation on the Grid data.
The query parameters that help you perform the server-side operations are as follows.
Server side operations such as sorting, filtering, paging are performed bythe PerformSorting, PerfomWherFilter, PerformSkip and PerformTake methods. |
<ej-grid id="Grid" allow-paging="true" action-complete="complete">
<e-datamanager url="/Home/Data" update-url="/Home/CellEditUpdate" insert-url="/Home/CellEditInsert" remove-url="/Home/CellEditDelete" adaptor="UrlAdaptor" />
<e-edit-settings allow-adding="true" allow-editing="true" dialog-editor-template-id="#template" edit-mode="DialogTemplate" />
<e-toolbar-settings show-toolbar="true" toolbar-items="@(new List<string>() {"add","edit","delete","update","cancel" })" />
<e-columns>
<e-column field="OrderID" header-text="Order ID" is-primary-key="true" default-value="0" text-align="Right" width="75"></e-column>
<e-column field="CustomerID" header-text="Customer ID" width="80"></e-column>
<e-column field="EmployeeID" header-text="Employee ID" text-align="Left" width="75"></e-column>
<e-column field="Freight" header-text="Freight" format="{0:C2}" text-align=Right width="75"></e-column>
<e-column field="ShipCity" header-text="Ship City" width="110"></e-column>
</e-columns>
</ej-grid>
public ActionResult Data([FromBody]DataManager dm)
{
IEnumerable Data = _context.Orders.Take(100).ToList();
Syncfusion.JavaScript.DataSources.DataOperations operation = new Syncfusion.JavaScript.DataSources.DataOperations();
if (dm.Sorted != null && dm.Sorted.Count > 0) //Sorting
{
Data = operation.PerformSorting(Data, dm.Sorted);
}
if (dm.Where != null && dm.Where.Count > 0) //Filtering
{
Data = operation.PerformWhereFilter(Data, dm.Where, dm.Where[0].Operator);
}
if (dm.Search != null && dm.Search.Count > 0) //searching
{
Data = operation.PerformSearching(Data, dm.Search);
}
int count = Data.AsQueryable().Count();
if (dm.Skip != 0)
{
Data = operation.PerformSkip(Data, dm.Skip);
}
if (dm.Take != 0)
{
Data = operation.PerformTake(Data, dm.Take);
}
return Json(new { result = Data, count = count });
} } |
<ej-grid id="Grid" allow-paging="true" action-complete="complete">
<e-datamanager url="/Home/Data" update-url="/Home/CellEditUpdate" insert-url="/Home/CellEditInsert" remove-url="/Home/CellEditDelete" adaptor="UrlAdaptor" />
<e-edit-settings allow-adding="true" allow-editing="true" dialog-editor-template-id="#template" edit-mode="DialogTemplate" />
<e-toolbar-settings show-toolbar="true" toolbar-items="@(new List<string>() {"add","edit","delete","update","cancel" })" />
<e-columns>
<e-column field="OrderID" header-text="Order ID" is-primary-key="true" default-value="0" text-align="Right" width="75"></e-column>
<e-column field="CustomerID" header-text="Customer ID" width="80"></e-column>
<e-column field="EmployeeID" header-text="Employee ID" text-align="Left" width="75"></e-column>
<e-column field="Freight" header-text="Freight" format="{0:C2}" text-align=Right width="75"></e-column>
<e-column field="ShipCity" header-text="Ship City" width="110"></e-column>
</e-columns>
</ej-grid>
HomeController.cs
public ActionResult CellEditInsert([FromBody]EditParams value)
{
var datas = _context;
datas.Orders.Add(value.value);
datas.SaveChanges();
return Json(value);
}
public ActionResult CellEditUpdate([FromBody]EditParams value)
{
var db = _context;
db.Entry(value.value).State = EntityState.Modified;
db.SaveChanges();
return Json(value);
}
public ActionResult CellEditDelete([FromBody]EditParams value)
{
var db = _context;
Orders order = db.Orders.Where(c => c.OrderID == Convert.ToInt32(value.key)).FirstOrDefault();
db.Orders.Remove(order);
db.SaveChanges();
return Json(order);
}
Model/NORTHWND.cs
public partial class Orders
{
[Key]
public int OrderID { get; set; }
public string CustomerID { get; set; }
public int EmployeeID { get; set; }
public decimal? Freight { get; set; }
public DateTime? OrderDate { get; set; }
public string ShipCity { get; set ; }
}
public class EditParams
{
public string key { get; set; }
public string action { get; set; }
public string keyColumn { get; set; }
public Orders value { get; set; }
} |