[CLOSED] MVC Gridpanel Form Post

  1. #1

    [CLOSED] MVC Gridpanel Form Post

    Heya,

    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]
  2. #2
    Hi @MWM2Dev,

    There are two tasks.

    1. Submitting a GridPanel's data.

    A GridPanel's doesn't submit its data automatically.

    To get it in POST you can put it to a Hidden field. You can do it just before submitting. To extract data from a GridPanel you can use its getRowsValues method.

    There is also the useful submitData method if you want just submit a GridPanel's data. Please see the example.
    https://examples2.ext.net/#/GridPane...it_to_Handler/

    2. Getting a GridPane's data within a controller as a Model instance.

    You can use a ModelBinder attribute. Please follow this link for details.
    http://forums.ext.net/showthread.php...l=1#post105622
  3. #3
    Thanks Daniil, worked like a charm!

Similar Threads

  1. Replies: 1
    Last Post: Apr 01, 2013, 12:34 PM
  2. Replies: 0
    Last Post: Aug 14, 2012, 2:54 PM
  3. Replies: 0
    Last Post: Aug 14, 2012, 2:48 PM
  4. [CLOSED] Post ordered gridpanel to server
    By Pablo_Azevedo in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Nov 29, 2011, 10:14 AM
  5. Replies: 3
    Last Post: Jan 13, 2010, 3:07 AM

Posting Permissions