I for the life of me can't figure out the problem.
I've got 3 grid controls, all are having the same behavior.
The object that is passed to the Insert or Save action appears to be an instance of an object, but all of the properties are null. Its impossible to put information into the repository if it all comes across as NULL....
Here is the Grid definition:
@(Html.Syncfusion().Grid<Vehicle>("VehicleListGrid")
.ActionMode(ActionMode.JSON)
.Datasource(Model.Vehicles)
.Caption("Vehicles")
.EnablePaging() /*Paging Enabled*/
/*.Grouping( group => group.GroupDescriptors(grouped => grouped.Add(c=>c.VIN)).IsExpanded(true)) Grouping Enabled for VIN */
.AllowResizing(true)
.FrozenColumns(1)
.Column(cols =>
{
cols.Add(c => c.VIN).HeaderText("VIN").TextAlign(Syncfusion.Mvc.Grid.TextAlignment.Right).Width(130);
cols.Add(c => c.Type).HeaderText("Type").TextAlign(Syncfusion.Mvc.Grid.TextAlignment.Right).Width(200).CellEditType(CellEditType.DropdownEdit);
cols.Add(c => c.Make).HeaderText("Make").TextAlign(Syncfusion.Mvc.Grid.TextAlignment.Right).Width(130);
cols.Add(c => c.Model).HeaderText("Model").TextAlign(Syncfusion.Mvc.Grid.TextAlignment.Right).Width(130);
cols.Add(c => c.Year).HeaderText("Year").TextAlign(Syncfusion.Mvc.Grid.TextAlignment.Right).Width(100);
cols.Add(c => c.Color).HeaderText("Color").TextAlign(Syncfusion.Mvc.Grid.TextAlignment.Right).Width(100);
cols.Add(c => c.LicensePlate).HeaderText("Plate").TextAlign(Syncfusion.Mvc.Grid.TextAlignment.Right).Width(100);
cols.Add(c => c.Odometer).HeaderText("Odometer").TextAlign(Syncfusion.Mvc.Grid.TextAlignment.Right).Width(100).CellEditType(CellEditType.NumericEdit);
})
.ClientSideEvents(events => { events.OnCellEdit("SetDropDownData"); })
.Mappers(mapper => { mapper.InsertAction("AddVehicle").SaveAction("SaveVehicle").DeleteAction("DeleteVehicle").Action("Vehicle"); })
.Editing(edit => { edit.AllowEdit(true).AllowNew(true).AllowDelete(true); edit.EditMode(GridEditMode.AutoExcel); edit.AddNewRowPosition(RowPosition.Bottom); edit.PrimaryKey(key => key.Add(p => p.VIN)); })
.ToolBar(tools => { tools.Add(GridToolBarItems.AddNew).Add(GridToolBarItems.Edit).Add(GridToolBarItems.Delete).Add(GridToolBarItems.Update).Add(GridToolBarItems.Cancel); })
)
and here is the code from the controller:
#region Vehicle Grid
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult Vehicle(PagingParams args)
{
IEnumerable data = Models.VehicleRepository.GetAllRecords();
return data.GridJSONActions<Vehicle>();
}
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult AddVehicle(Vehicle veh)
{
Models.VehicleRepository.Add(veh);
var data = Models.VehicleRepository.GetAllRecords();
return data.GridJSONActions<Vehicle>();
}
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult SaveVehicle(Vehicle veh)
{
Models.VehicleRepository.Update(veh);
var data = Models.VehicleRepository.GetAllRecords();
return data.GridJSONActions<Vehicle>();
}
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult DeleteVehicle(string VIN)
{
if (ModelState.IsValid)
{
Models.VehicleRepository.Delete(VIN);
}
var data = Models.VehicleRepository.GetAllRecords();
return data.GridJSONActions<Vehicle>();
}
#endregion Vehicle Grid
Vehicle is defined as:
public class Vehicle
{
[Display(Name = "Year")]
public int Year { get; set; }
[Display(Name = "Make")]
public string Make { get; set; }
[Display(Name = "Model")]
public string Model { get; set; }
[Display(Name = "VIN")]
public string VIN { get; set; }
[Display(Name = "License Plate")]
public string LicensePlate { get; set; }
[Display(Name = "Color")]
public string Color { get; set; }
[Display(Name = "Odometer")]
public int Odometer { get; set; }
[Display(Name = "Membership Type")]
public string Type { get; set; }
}
When SaveVehicle or AddVehicle is called, the veh object is valid, but all of the data (Year, Make, Model, VIN, etc) are all NULL.
Any ideas?
I've wasted hours on trying to figure out this nonsense.