function evaluate() { var form = $('#__AjaxAntiForgeryForm'); var token = $('input[name="__RequestVerificationToken"]', form).val(); var grid = document.getElementById("OrderHistoryGrid").ej2_instances[0]; if (grid.getSelectedRowIndexes().length) { let selectedRow = grid.getSelectedRowIndexes()[0]; let selectedRec = grid.getSelectedRecords()[0]; $.ajax({ url: "/Orders/EvaluateOrder", type: "POST", data: { __RequestVerificationToken: token, orderData: selectedRec }, success: function (data) {
====== What to write here ? =====
}, error: function (jqXHR) { alert("Error: can't evaluate: " + jqXHR.responseText) } }); } else { alert("No records selected."); }
}
document.getElementById('btn').addEventListener('click', function (e) {
var grid = document.getElementById('Grid').ej2_instances[0];
var selectedRecords = grid.getSelectedRecords();
var index = grid.getSelectedRowIndexes()[0];
var data = JSON.stringify({ value: selectedRecords[0] });
var ajax = new ej.base.Ajax({
url: "/Home/Update",
type: "POST",
data: data
});
ajax.send().then(function (data) {
grid.editModule.updateRow(index, JSON.parse(data));
}).catch(function (xhr) {
console.log(xhr);
});
}); |
function load() {
this.columns[3].commands[0].buttonOption.click = function (args) { //click event for custom command button
var grid = document.getElementsByClassName('e-grid')[0].ej2_instances[0];
var rowObj = grid.getRowObjectFromUID(ej.base.closest(args.target, '.e-row').getAttribute('data-uid'));
console.log(rowObj.data); // You can get the respective row data here
}
}; |
public class HomeController : Controller { public static List<Orders> order = new List<Orders>(); public ActionResult Index()
Just in case, my object is like this:
public class OrderHistory { public OrderHistory() { } public OrderHistory(int orderId, DateTime dateTimeUtc) { OrderId = orderId; DateTimeUtcTicks = dateTimeUtc.Ticks; } [Key] public int Id { get; set; } [Index("IX_OrderIdAndDate", Order = 0, IsUnique = true)] public int OrderId { get; set; } public Order Order { get; set; } [Index("IX_OrderIdAndDate", Order = 1, IsUnique = true)] public long DateTimeUtcTicks { get; set; } [NotMapped] public string DateTimeUtcTicksString { get { return DateTimeUtcTicks.ToString(); } set { DateTimeUtcTicks = Convert.ToInt64(value); } } [NotMapped] public DateTime DateTimeUtc { get { return new DateTime(DateTimeUtcTicks, DateTimeKind.Utc); } } public bool AlreadyExistedInDb { get; set; } public string ShippingParametersChanges { get; set; } public bool ShippingParametersChanged { get { return !string.IsNullOrWhiteSpace(ShippingParametersChanges); } } public bool ShippingQuoteRequested { get; set; } public bool ShippingQuoteReceived { get; set; } public string ShippingQuoteError { get; set; } public List<ShippingService> ProposedShippingServices { get; set; } public string PreviousServiceCode { get; set; } public string NewServiceCode { get; set; } public bool NewServiceCodeSentToApi { get; set; } public bool NewServiceCodeApplied { get; set; } public string NewServiceCodeError { get; set; } }Thank you
public class HomeController : Controller
{
public List<Orders> order = new List<Orders>();
public ActionResult Index()
{
if (order.Count == 0)
BindDataSource();
ViewBag.data = order;
return View();
}
public ActionResult Update(Orders value)
{
BindDataSource();
var data = order.Where(or => or.OrderID == value.OrderID).FirstOrDefault();
if(data != null)
{
data.OrderID = value.OrderID;
data.CustomerID = "VINET";
data.EmployeeID = 1;
data.OrderDate = new DateTime(2019, 01, 30);
data.ShipCity = "Brazil";
}
return Json(data);
}
public void BindDataSource()
{
order.Add(new Orders(10248, 1, "1", "Reims", new DateTime(2108, 11, 12)));
......
}
} |