BoldSignEasily embed eSignatures in your .NET applications. Free sandbox with native SDK available.
<ej-grid id="Grid" allow-paging="true" allow-sorting="true" action-complete="onComplete">
<e-datamanager json="(IEnumerable<Orders>)ViewBag.datasource" remove-url="Home/Delete" update-url="Home/Update" insert-url="Home/Insert" adaptor="remoteSaveAdaptor"></e-datamanager>
<e-edit-settings allow-adding="true" allow-editing="true" allow-deleting="true" ></e-edit-settings>
<e-columns>
<e-column field="OrderID" is-primary-key="true" header-text="Order ID" text-align="Right"></e-column>
<e-column field="CustomerID" header-text="CustomerID" edit-type="String"></e-column>
<e-column field="ShipCity" header-text="Ship City datasource="(IEnumerable<Employee>)ViewBag.datasource" edit-type="Dropdown"></e-column>
</e-columns>
</ej-grid> |
Serverside:-
public class HomeController : Controller
{
private NORTHWNDContext _context;
public HomeController(NORTHWNDContext context)
{
_context = context;
}
public IActionResult Index()
{
List<Orders> Result = _context.Orders.Take(100).ToList();
ViewBag.datasource = Result;
List<Employee> data = new List<Employee>();
data = db.Employees.ToList();
ViewBag.DataSource = data;
return View();
}
}
public List<Orders> GetData()
{
List<Orders> datas = _context.Orders.Take(100).ToList();
return datas;
}
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 });
}
public class DataResult
{
public IEnumerable result { get; set; }
public int count { get; set; }
public IEnumerable aggregate { get; set; }
public IEnumerable groupDs { get; set; }
}
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);
}
|