Hi Joseph,
Sorry but Still not working. Note I'm using Spanish locale. My model class:
public class OrderLineViewModel
{
public int Id { get; set; }
public int SalesOrderId { get; set; }
public string ProductName { get; set; }
public string ProductNumber { get; set; }
public decimal Price { get; set; }
public DateTime? Expiration { get; set; }
}
This is grid rendering code:
<script>new ejs.grids.Grid({ "allowExcelExport": true, "allowFiltering": true, "allowPaging": true, "allowSorting": true, "allowTextWrap": true, "columns": [ { "allowEditing": false, "field": "ProductName", "headerText": "Nombre", "maxWidth": "400", "minWidth": "300", "width": "350" }, { "allowEditing": false, "field": "IsKit", "headerText": "Kit", "maxWidth": "75", "minWidth": "50", "template": "#isKitTemplate", "width": "75" }, { "allowEditing": false, "field": "ProductType", "headerText": "Tipo", "maxWidth": "175", "minWidth": "125", "width": "150" }, { "allowEditing": false, "field": "ProductNumber", "headerText": "#", "maxWidth": "125", "minWidth": "75", "width": "100" }, { "allowEditing": false, "field": "Price", "format": "C2", "headerText": "Precio €", "hideAtMedia": "(min-width: 1200px)", "maxWidth": "150", "minWidth": "100", "width": "125" }, { "allowEditing": false, "field": "Quantity", "headerText": "Cantidad", "hideAtMedia": "(min-width: 1200px)", "maxWidth": "125", "minWidth": "75", "width": "100" }, { "allowEditing": false, "field": "WarehousePending", "headerText": "Pendiente de entrada", "hideAtMedia": "(min-width: 1200px)", "maxWidth": "125", "minWidth": "75", "width": "100" }, { "field": "Lot", "headerText": "Lote", "maxWidth": "125", "minWidth": "75", "width": "100" }, { "customFormat": { "type": "date", "format": "dd/MM/yyyy" }, "editType": "datepickeredit", "field": "Expiration", "headerText": "Caducidad", "hideAtMedia": "(min-width: 1200px)", "maxWidth": "150", "minWidth": "100", "type": "date", "width": "100" }, { "editType": "numericedit", "field": "WarehouseEntry", "format": "N", "headerText": "Entrada", "hideAtMedia": "(min-width: 1200px)", "maxWidth": "125", "minWidth": "75", "width": "100" } ], "dataSource": ejs.data.DataUtil.parse.isJson([ { "Id": 10, "SalesOrderId": 6, "ProductId": 51, "AccountId": 10, "ProductType": "Producto", "ProductName": "VITAMINAS CAPIVANCE", "ProductNumber": "IPLPF-006", "Price": 25.00, "Quantity": 50.00, "Tax": 0.00, "Total": 1250.0000, "IsKit": false, "WarehousePending": 50.00, "WarehouseEntry": 0.0, "Lot": "S/L", "Expiration": "2023-06-22T17:38:38.4157855+02:00" } ]), "editSettings": { "allowEditing": true, "mode": "Batch" }, "filterSettings": { "immediateModeDelay": 1500.0, "type": "Excel" }, "frozenColumns": 0.0, "frozenRows": 0.0, "locale": "es", "pageSettings": { "currentPage": 1.0, "pageCount": 8.0, "pageSize": 20.0 }, "searchSettings": { "fields": [ "Vendor", "ProductNumber", "Name", "Type" ] }, "selectedRowIndex": -1.0, "showColumnChooser": true, "toolbar": [ "ExcelExport", "Search", "ColumnChooser", "Update" ], "beforeBatchSave": saveBatch, "excelExportComplete": excelExportComplete, "queryCellInfo": customiseCell, "toolbarClick": toolbarClick }).appendTo("#Grid");
Javascript saveBatch function:
function saveBatch(args) {
var data = args.batchChanges.changedRecords;
var id = @Model.Order.Id;
var token = $('input:hidden[name="__RequestVerificationToken"]').val();
$.ajax({
type: "POST",
url: "/WarehouseOrderLine/Create?handler=Selected",
beforeSend: function (xhr) {
xhr.setRequestHeader("XSRF-TOKEN",
$('input:hidden[name="__RequestVerificationToken"]').val());
},
data: { id: id, selected: data, __RequestVerificationToken: token }, //Pass the selected row index value to server side
success: function (response) {
window.location.rel='nofollow' href = '/WarehouseOrderLine/Create/?id=' + id;
},
failure: function (response) {
alert(response);
}
});
}
This is the JSON Post Data after grid saving where Expiration field is not converted to DateTime type on post page handler:
public async Task
Thanks for your update.
It's has been useful, now it's working fine.
The key has been the use in AJAX call with this parameters that I was not using:
datatype: "text",
contentType: "application/json; charset=utf-8",
data: JSON.stringify(rowsDetails)
Thanks