[CLOSED] MVC Grid - Server Databinding

  1. #1

    [CLOSED] MVC Grid - Server Databinding

    How can I bind a grid store to a model from the server? I had thought that something like this would work:

    .Store(Sub(action)
                               action.Add(Html.X.Store().AutoLoad(True) _
                                .Model(Sub(mdl)
                                               mdl.Add(Html.X().Model.Fields(Sub(fields)
                                                                                     fields.Add(Html.X.ModelField.Name("Name"))
                                                                                     fields.Add(Html.X.ModelField.Name("UKCode"))
                                                                                     fields.Add(Html.X.ModelField.Name("DateSentToRI").Type(ModelFieldType.Date).DateFormat("M$"))
                                                                                     fields.Add(Html.X.ModelField.Name("DateSignedDocSentToRI").Type(ModelFieldType.Date).DateFormat("M$"))
                                                                                     fields.Add(Html.X.ModelField.Name("Code"))
                                                                                     fields.Add(Html.X.ModelField.Name("TrackDates").Type(ModelFieldType.Boolean))
                                                                                     fields.Add(Html.X.ModelField.Name("DateReceivedFromRI").Type(ModelFieldType.Date).DateFormat("M$"))
                                                                                     fields.Add(Html.X.ModelField.Name("NeverSigning").Type(ModelFieldType.Boolean))
                                                                             End Sub))
                                       End Sub) _
                                .PageSize(20).DataSource(Model))
                       End Sub)
    (Model is a List(of CustomType)) However, this doesn't work. Can you tell me if this is possible, and if so how?
    Last edited by Daniil; May 04, 2012 at 9:52 PM. Reason: [CLOSED]
  2. #2
    Hi,

    Well, it works on my side. Here is my test case.

    Example View
    @inherits System.Web.Mvc.WebViewPage<List<object>>
    
    <!DOCTYPE html>
    
    <html>
    <head>
        <title>Ext.NET Razor Example</title>    
    </head>
    <body>    
        @Html.X().ResourceManager()
    
        @(Html.X().GridPanel()
            .AutoHeight(true)
            .Store(store =>
                store.Add(
                    Html.X().Store()
                        .Model(m =>
                            m.Add(Html.X().Model()
                                .Fields(f =>
                                {
                                    f.Add(Html.X().ModelField().Name("test1"));
                                    f.Add(Html.X().ModelField().Name("test2"));
                                    f.Add(Html.X().ModelField().Name("test3"));
                                })
                            )
                        )
                        .DataSource(Model)
                )
            )
            .ColumnModel(cm =>
            {
                cm.Add(Html.X().Column().DataIndex("test1").Text("Test 1"));
                cm.Add(Html.X().Column().DataIndex("test2").Text("Test 2"));
                cm.Add(Html.X().Column().DataIndex("test3").Text("Test 3"));
            })
        )
    </body>
    </html>
    Example Controller Action
    public ActionResult TestRazor()
    {
        return View(new List<object>() 
        {
            new 
            { 
                test1 = "test11", 
                test2 = "test12", 
                test3 = "test13" 
            },
            new 
            { 
                test1 = "test21", 
                test2 = "test22", 
                test3 = "test23" 
            }
        });
    }

Similar Threads

  1. [CLOSED] Reading grid in the server
    By Pablo_Azevedo in forum 1.x Legacy Premium Help
    Replies: 3
    Last Post: Jul 12, 2012, 7:51 PM
  2. Replies: 4
    Last Post: Oct 24, 2011, 3:34 AM
  3. Replies: 13
    Last Post: Aug 11, 2011, 6:11 AM
  4. Replies: 0
    Last Post: Jun 21, 2011, 2:51 AM
  5. [CLOSED] [1.0] Grid column with databinding
    By edigital in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: Jun 23, 2010, 4:27 PM

Tags for this Thread

Posting Permissions