<ej-grid id="Grid" allow-filtering="true" allow-paging="true" selected-row-index="0">
<e-datamanager url="//mvc.syncfusion.com/Services/Northwnd.svc/Orders" cross-domain="true" />
.. .
</ej-grid> |
<ej-grid id="Grid" allow-paging="true" allow-sorting="true">
<e-datamanager url="/Home/AdrTypDataAll" adaptor="UrlAdaptor" />
<e-columns>
<e-column field="ID" header-text="TitelID"></e-column>
<e-column field="AdresseTyp" header-text="AdrTyp Kurz" text-align=Left></e-column>
<e-column field="CustomerID" header-text="Customer ID" text-align=Left></e-column>
</e-columns>
</ej-grid>
public ActionResult AdrTypDataAll([FromBody]DataManager dm)
{
IEnumerable DataSource = order;
DataOperations ds = new DataOperations();
int count = DataSource.Cast<Orders>().ToList().Count();//count
if (dm.Skip != null)
DataSource = ds.PerformSkip(DataSource, dm.Skip);
if (dm.Take != null)
DataSource = ds.PerformTake(DataSource, dm.Take);
return Json(new { result = DataSource, count=count });
} |
public ActionResult AdrTypDataAll([FromBody]DataManager dm)
{
IEnumerable DataSource = order;
DataOperations ds = new DataOperations();
int count = DataSource.Cast<Orders>().ToList().Count();//count
if (dm.Skip >= 0)
DataSource = ds.PerformSkip(DataSource, dm.Skip);
if (dm.Take > 0)
DataSource = ds.PerformTake(DataSource, dm.Take);
return Json(new { result = DataSource, count=count });
} |
<ej-grid id="Grid" allow-paging="true" allow-sorting="true" allow-filtering="true">
<e-datamanager url="/Home/AdrTypDataAll"
update-url="/Home/CellEditUpdate"
insert-url="/Home/CellEditInsert"
remove-url="/Home/CellEditDelete" adaptor="UrlAdaptor" />
<e-edit-settings allow-adding="true" allow-deleting="true" allow-editing="true" />
<e-toolbar-settings show-toolbar="true" toolbar-items=@(new List<string>()
{ "add","edit","delete","update","cancel" })>
</e-toolbar-settings>
. . .
. . .
</ej-grid>
public ActionResult CellEditUpdate([FromBody]CRUDModel<Orders> value)
{
var ord = value.Value;
Orders val = order.Where(or => or.ID == ord.ID).FirstOrDefault();
val.ID = ord.ID;
val.EmployeeID = ord.EmployeeID;
val.CustomerID = ord.CustomerID;
val.Freight = ord.Freight;
val.OrderDate = ord.OrderDate;
val.AdresseTyp = ord.AdresseTyp;
return Json(value.Value);
}
public ActionResult CellEditInsert([FromBody]CRUDModel<Orders> value)
{
value.Value.ID = order.LastOrDefault().ID + 1;
order.Insert(0, value.Value);
return Json(value.Value);
}
public ActionResult CellEditDelete([FromBody]CRUDModel<Orders> value)
{
order.Remove(order.Where(or => or.ID == int.Parse(value.Key.ToString())).FirstOrDefault());
return Json(value);
}
|
<ej-grid id="Grid" allow-paging="true" is-responsive="true" min-width="400" >
<e-datamanager url="/Home/AdrTypDataAll" adaptor="UrlAdaptor" />
</ej-grid>
public ActionResult AdrTypDataAll([FromBody]DataManager dm)
{
IEnumerable DataSource = order;
DataOperations ds = new DataOperations();
. ..
. .. . .
return Json(new { result = DataSource, count=count });
} |
<ej-grid id="Grid" allow-paging="true" allow-sorting="true" >
<e-toolbar-settings show-toolbar="true" toolbar-items=@(new List<string>()
{ "excelExport","wordExport" })>
</e-toolbar-settings>
. . .
. . .
</ej-grid>
public ActionResult ExportToExcel(string GridModel)
{
ExcelExport exp = new ExcelExport();
var DataSource = order.ToList();
GridProperties gridProp = ConvertGridObject(GridModel);
GridExcelExport excelExp = new GridExcelExport();
excelExp.FileName = "Export.xlsx";
excelExp.Excelversion = ExcelVersion.Excel2010;
excelExp.Theme = "flat-saffron";
return exp.Export(gridProp, DataSource, excelExp);
}
.. . .
. . .
private GridProperties ConvertGridObject(string gridProperty)
{
GridProperties gridProp = new GridProperties();
gridProp = (GridProperties)JsonConvert.DeserializeObject(gridProperty, typeof(GridProperties));
return gridProp;
} |