Hello I am using Kendo grid to edit price lists.
I am trying to edit single value in table:
And I am having troubles passing edited value in grid to my controller:
I am always getting back empty datetime value (by empty I mean {1. 1. 0001 0:00:00}) same problem is with 2 other columns using DateTime property (Created and ValidFrom). Rest of the values are posted back correctly. I was trying to get those values using string DateTillStr = Request.Params["ValidTill"]; but if I check my GET in firebug I can see grid is not sending back this value inside Request it sends only NON Datetime values of my model object. Like this:
Nothing more nothing less, only these 7 attributes I am missing rest 4 from my model:
Is there some other way to post these data back? I figured out I can attach additional data to Update request but I had an issue how to identify edited row in the table in javascript function (I know how to identify selected value but not edited).
Please help me I am quite desperate.
David Ježek
I am trying to edit single value in table:
@(Html.Kendo().Grid(Model).Name("PriceList") .Columns(columns => { columns.Bound(p => p.Id).Hidden(); columns.Bound(p => p.Name); columns.Bound(p => p.ValidFrom).Format("{0:dd.MM.yyyy h:mm:ss}"); columns.Bound(p => p.ValidTill).Format("{0:dd.MM.yyyy h:mm:ss}"); columns.Bound(p => p.Created).Format("{0:dd.MM.yyyy h:mm:ss}"); columns.Bound(p => p.UserName); columns.Bound(p => p.FilePath); columns.Command(command => { command.Edit(); command.Destroy(); }); }) .DataSource(dataSource => dataSource.Ajax() .Model(model => { model.Id(p => p.Id); model.Field(p => p.ValidFrom).Editable(false); model.Field(p => p.ValidTill).Editable(true); model.Field(p => p.Created).Editable(false); model.Field(p => p.UserName).Editable(false); model.Field(p => p.FilePath).Editable(false); model.Field(p => p.Name).Editable(false); }) .Read("PriceList_Read", "Admin") .Destroy("PriceList_Editing_Destroy", "Admin") .Update(update=>update.Action("PriceList_Editing_Update", "Admin")) .Events(e=>e.Error("error_handler")) ) .Editable(editable => editable.Mode(GridEditMode.InLine)) .AutoBind(true))And I am having troubles passing edited value in grid to my controller:
public ActionResult PriceList_Editing_Update([DataSourceRequest] DataSourceRequest request, PriceListViewModel model) { int Id = model.Id; string Name = model.Name; DateTime date = model.ValidTill; // 0001 00:00:00 value all the time return View("Index", GetViewResult()); }I am always getting back empty datetime value (by empty I mean {1. 1. 0001 0:00:00}) same problem is with 2 other columns using DateTime property (Created and ValidFrom). Rest of the values are posted back correctly. I was trying to get those values using string DateTillStr = Request.Params["ValidTill"]; but if I check my GET in firebug I can see grid is not sending back this value inside Request it sends only NON Datetime values of my model object. Like this:
Actual falseFilePath D:\Projects\CPSkla\CPSkla\App_Data\Cen°k 2012_10.xlsxId 23Name Testovací ceníkUser 0User1 nullUserName djezekNothing more nothing less, only these 7 attributes I am missing rest 4 from my model:
public partial class PriceListView { public int Id { get; set; } public int User { get; set; } public string Name { get; set; } public System.DateTime ValidFrom { get; set; } public System.DateTime ValidTill { get; set; } public string FilePath { get; set; } public Nullable<System.DateTime> Created { get; set; } public Nullable<System.DateTime> Updated { get; set; } public bool Actual { get; set; } public string UserName { get; set; } }Is there some other way to post these data back? I figured out I can attach additional data to Update request but I had an issue how to identify edited row in the table in javascript function (I know how to identify selected value but not edited).
Please help me I am quite desperate.
David Ježek