May 16, 2013, 9:02 AM
[CLOSED] MVC Gridpanel Form Post
Heya,
I have the following (Complex) Model:
However on a standard MVC FormPost the Controller doesnt map the gridpanel to the Model.
So a few questions arise:
1) Is it even possible to databind a gridpanel in my controller to the ReleaseModel on a (standard)form submit?
2) If the above is not possible what would you recommand on how to bind the gridpanel in the controller?
I have the following (Complex) Model:
namespace ReleaseManager.Models
{
using System;
using System.Collections.Generic;
using ReleaseManager.Database;
/// <summary>
/// The release model.
/// </summary>
public class ReleaseModel
{
/// <summary>
/// Initializes a new instance of the <see cref="ReleaseModel" /> class.
/// </summary>
public ReleaseModel()
{
this.Checklist = new ChecklistModel();
}
/// <summary>
/// Gets or sets the title.
/// </summary>
/// <value>
/// The title.
/// </value>
public string Title { get; set; }
/// <summary>
/// Gets or sets the description.
/// </summary>
/// <value>
/// The description.
/// </value>
public string Description { get; set; }
/// <summary>
/// Gets or sets the release date.
/// </summary>
/// <value>
/// The release date.
/// </value>
public DateTime ReleaseDate { get; set; }
/// <summary>
/// Gets or sets the projects.
/// </summary>
/// <value>
/// The projects.
/// </value>
public List<Project> Projects { get; set; }
/// <summary>
/// Gets or sets the projects.
/// </summary>
/// <value>
/// The projects.
/// </value>
public List<Project> SelectedProjects { get; set; }
/// <summary>
/// Gets or sets the checklists.
/// </summary>
/// <value>
/// The checklists.
/// </value>
public ChecklistModel Checklist { get; set; }
/// <summary>
/// Gets or sets the releases.
/// </summary>
/// <value>
/// The releases.
/// </value>
public List<Release> Releases { get; set; }
}
}
namespace ReleaseManager.Models
{
using System.Collections.Generic;
/// <summary>
/// The checklist model.
/// </summary>
public class ChecklistModel
{
/// <summary>
/// Initializes a new instance of the <see cref="ChecklistModel" /> class.
/// </summary>
public ChecklistModel()
{
this.Points = new List<PointModel>();
}
/// <summary>
/// Gets or sets the description.
/// </summary>
/// <value>
/// The description.
/// </value>
public string Description { get; set; }
/// <summary>
/// Gets or sets the points.
/// </summary>
public List<PointModel> Points { get; set; }
}
}
namespace ReleaseManager.Models
{
using System;
using Ext.Net;
using Ext.Net.MVC;
/// <summary>
/// The point model.
/// </summary>
[Model(Name = "CheckPoint")]
[JsonWriter(Encode = true, Root = "data")]
public class PointModel
{
/// <summary>
/// Gets or sets the description.
/// </summary>
public string Description { get; set; }
/// <summary>
/// Gets or sets the position.
/// </summary>
/// <value>
/// The position.
/// </value>
[Field(Ignore = true)]
public int Position { get; set; }
/// <summary>
/// Gets or sets the duration.
/// </summary>
[ModelField(Type = ModelFieldType.Date, DateFormat = "hh/mm")]
public TimeSpan Duration { get; set; }
}
}
Html.X().GridPanel().ID("checkpoint").Height(200).Store(Html.X().StoreFor(model => model.Checklist.Points)).ColumnModel(Html.X().RowNumbererColumn().Width(25).Text("#"), Html.X().ColumnFor(Model.Checklist.Points, model => model.Duration).ToBuilder<Column.Builder>().Width(100).Editor(Html.X().TimeField().AllowBlank(false)), Html.X().ColumnFor(Model.Checklist.Points, model => model.Description).ToBuilder<Column.Builder>().Flex(1).Editor(Html.X().TextField().AllowBlank(false)))
And with a gridpanel I want to add Points to the ChecklistModel which is part of the ReleaseModel.However on a standard MVC FormPost the Controller doesnt map the gridpanel to the Model.
So a few questions arise:
1) Is it even possible to databind a gridpanel in my controller to the ReleaseModel on a (standard)form submit?
2) If the above is not possible what would you recommand on how to bind the gridpanel in the controller?
Last edited by Daniil; May 16, 2013 at 1:19 PM.
Reason: [CLOSED]