[CLOSED] StoreForModel : Get grid values in controller method as list of object

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1

    [CLOSED] StoreForModel : Get grid values in controller method as list of object

    Hi
    I have a question ,I prepare a grid with StoreforModel and try to get grid value on submit button click as list of object in controller action ,Is it possible?

    @model e.Controllers.StoreforModelEmployee
    @{
        var X=Html.X();
       
    }
    <script>
        function fullNameBuilder(value, record) {
            return record.data.LastName + ', ' + record.data.FirstName;
        }
    </script>
    <h1>Store for Model</h1>
    <p>Automatically build store for a model</p>
    @Html.X().ResourceManager()
    @(
    @X.FormPanel()
    .ID("f")
    .Items
    (
     Html.X().GridPanel()
                .Title("Employees")
                .Width(500)
                .Height(200)
                .ForceFit(true)
                .Plugins(X.CellEditing())
                .Store(
                    Html.X().StoreFor<e.Controllers.StoreforModelEmployee>()
                )
                .ColumnModel(
                    Html.X().ColumnFor(m => m.Id).ToBuilder<Column.Builder>().Width(30),
                    Html.X().Column().DataIndex("FullName").Text("Full Name").Editor(X.TextField()),
                    Html.X().ColumnFor(m => m.FirstName),
                    Html.X().ColumnFor(m => m.LastName)
                )
               
                
        )
        .Buttons(
                X.Button()
               .Text("Submit")
               .DirectEvents(d=>{
                   d.Click.FormID = "f";
                   d.Click.Action = "submit";
               })
                )
        )
    public class StoreforModelController : Controller
        {
            //
            // GET: /StoreforModel/
    
            public ActionResult Index()
            {
                return View();
            }
    
            public ActionResult GetEmployees()
            {
                return this.Store(StoreforModelEmployee.GetAll());
            }
            public void submit(List<StoreforModelEmployee> _StoreforModelEmployee)
            {
            }
    
        }
    
        [Proxy(Read = "~/StoreforModel/GetEmployees")]
        [JsonReader(Root = "data")]
        [VirtualModelField(Name = "FullName", ConvertHandler = "fullNameBuilder")]
       // [ClientResource(Path = "~/Areas/Models/Content/storeHelpers.js")]
        public class StoreforModelEmployee
        {
            [ModelField(IDProperty = true)]
            public int Id
            {
                get;
                set;
            }
    
            public string FirstName
            {
                get;
                set;
            }
    
            public string LastName
            {
                get;
                set;
            }
    
            [ModelField(Ignore = true)]
            public string IgnoreField
            {
                get;
                set;
            }
    
            public static List<StoreforModelEmployee> GetAll()
            {
                return new List<StoreforModelEmployee> { 
                    new StoreforModelEmployee{ Id = 1, FirstName = "John", LastName = "Snow"},
                    new StoreforModelEmployee{ Id = 2, FirstName = "Fred", LastName = "Flintstone"},
                    new StoreforModelEmployee{ Id = 3, FirstName = "Andrew", LastName = "Fuller"}
                };
            }
        }
    I need the list in submit method as parameter.

    also I found there are no DateColumnFor option ,so how I manage date with Storefor approach?
    How I define IdProperty ?
    Last edited by Daniil; May 26, 2015 at 4:50 PM. Reason: [CLOSED]

Similar Threads

  1. Replies: 8
    Last Post: May 12, 2013, 6:19 PM
  2. Replies: 1
    Last Post: Apr 09, 2012, 1:07 PM
  3. [CLOSED] Uncaught TypeError: Object #<Object> has no method '***'
    By Sevilay Tanış in forum 1.x Legacy Premium Help
    Replies: 7
    Last Post: Mar 27, 2012, 4:44 PM
  4. Replies: 0
    Last Post: Oct 21, 2011, 3:04 AM
  5. Replies: 1
    Last Post: Nov 22, 2010, 9:07 AM

Posting Permissions