VBox MVC Show Grey Rectangle on GridPanel

  1. #1

    VBox MVC Show Grey Rectangle on GridPanel

    Hello, i'm starting a MVC project with Ext.Net. In my view, i have a gridpanel inside a vbox layout as follow

    @model ExtNetMvcApplication.Models.Plant
    @{
        var X = Html.X();
    }
    <html>
    <head>
        <title>Ext.NET MVC Sample</title>    
        <script type="text/javascript">
            var showData = function (grid) {
                grid.getStore().getProxy().setExtraParam('test', App.hiddenId.getValue());
                grid.getStore().reload();
                //Ext.getCmp('hiddenId').setValue(new Date().getMinutes().toString());
            };
        </script>
    </head>
    <body>
        @(Html.X().ResourceManager())
    @(X.Viewport()
            .Layout(LayoutType.Border)
            .Items(
                        X.Panel()
                            .Title("My Query")
                            .Region(Region.West)
                            .Border(true)
                            .BodyPadding(10)
                            .Layout(LayoutType.VBox)
                            .LayoutConfig(new VBoxLayoutConfig { Align = VBoxAlign.Stretch })
                            .Frame(true)
                            .Items(
                                X.Panel().Layout(LayoutType.Fit)
                                    .Items(
                                        X.Hidden().ID("hiddenId").Value("some value")
                                        ),
    
                                        X.Button().Text("Test")
                                        .Listeners(ls =>
                                            {
                                                ls.Click.Handler = "showData(App.GridPanel1)";
                                            }
                                        ),
                                        
                                        X.Panel().Layout(LayoutType.Fit).Flex(1)
                                        .Items(
                                X.GridPanel().ID("GridPanel1")
                                .Title("My Grid")
                                .Frame(true)
                                .Store(Html.X().StoreForModel()
                                        .AutoLoad(false)
                                        .Proxy(Html.X().AjaxProxy()
                                        .Url(Url.Action("Read"))
                                        .Reader(Html.X().JsonReader().RootProperty("data")))
                                    .PageSize(5)
                                    )
                                    .ColumnModel(Html.X().Column().DataIndex(Model, m => m.Common).Text("Common Name"),
                                                    Html.X().Column().DataIndex(Model, m => m.Botanical).Text("Botanical").Width(230),
                                                    Html.X().Column().DataIndex(Model, m => m.Light).Text("Light").Width(130)
                                            )
                                .SelectionModel(
                                    Html.X().RowSelectionModel().Mode(SelectionMode.Single).DirectEvents(de =>
                                    {
                                        de.SelectionChange.Url = Url.Action("SetTimeStamp");
                                        de.SelectionChange.Confirmation.Title = "Title";
                                    })
                                    )
    
                                .BottomBar(
                                    Html.X().PagingToolbar().HideRefresh(true)
                                        .DisplayInfo(true)
                                        .DisplayMsg("{2}")
                                        .EmptyMsg("0"))
            ) 
                        ),
                X.TabPanel()
                    .Region(Region.Center)
                    .Items(
                        X.Panel()
                            .Title("Center")
                            .Border(false)
                            .BodyPadding(6)
                            .Items(
                            Html.X().TextField().ID("TextField3").FieldLabel("Company Name").AllowBlank(false)
                        )
                ,
    
                        X.Panel()
                            .Title("Close Me")
                            .Closable(true)
                            .Border(false)
                            .BodyPadding(6)
                            .Html("Closeable Tab")
                    )
            )
            )
    </body>
    </html>
    And the controller is
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.Mvc;
    using Ext.Net;
    using Ext.Net.MVC;
    
    namespace ExtNetMvcApplication.Controllers
    {
        public class ViewportLayoutController : Controller
        {
            //
            // GET: /ViewportLayout/
    
            public ActionResult Index()
            {
                return View();
            }
    
            public ActionResult SetTimeStamp()
            {
                var txtField = this.GetCmp<TextField>("TextField3");
                txtField.Text = DateTime.Now.ToLongTimeString();
    
                return this.Direct();
            }
    
            public ActionResult Read(StoreRequestParameters parameters, string test)
            {
                    return this.Store(Models.Plant.PlantsPaging(parameters));
            }
        }
    }
    and my model exactly the same as the example.

    The layout is looking good until user click test button. It show a grey rectangle on top of gridpanel. Pls let me know what wrong with my vbox layout. thank you. Click image for larger version. 

Name:	before.png 
Views:	42 
Size:	43.3 KB 
ID:	24796Click image for larger version. 

Name:	after.png 
Views:	65 
Size:	38.0 KB 
ID:	24797
  2. #2
    Hello @browndong, and welcome to Ext.NET forums!..

    Sometimes dealing with layouts will require a lot of attention not to forget one or another specific trait of the layout setting.

    In your test case, you needed to give either a fixed width or a flex value to the panel in the west region. According to the documentation on border layout (see the notes in the summary of the feature), at least this was necessary to ensure the page would smoothly work. East, south and north will also require these settings. Omitting them may result in a working page but -- exactly as you witnessed -- layout refreshes may break, and that's a reasonably difficult aspect to tackle with.

    Here are some relevant discussions on the subject:
    - Post #9 in "Layout run failed" appears when displaying large no of dynamic MenuPanels inside Portals inside GroupTabPanel. I believe reading from the first post down to this 9th post is enough to understand the problems around it and debugging alternatives.
    - Border layout without region & CommandCOlumn. Points to the relevance of considering the notes in the docs of the border layout.

    As for the test case you provided, it was as hard to solve the issue as adding the .Flex(1) argument to line 23 of your view code. Properly indenting the razor syntax algorithm helps a lot identifying blocks and where the width/height or flex setting is missing.

    We appreciate providing the runnable test case, but indenting the code and pointing the exact example you based your test case from (so we could pull the class directly from it without having to search over) would greatly help! :)

    Anyway, hope the explanation above is clear and helps you make your page work smoothly!
    Fabrício Murta
    Developer & Support Expert
  3. #3
    thank you for the long explanation fabrizio. It solved my problem with the proper width of the gridpanel

Similar Threads

  1. [CLOSED] Not able to put space between containers in a VBox Layout
    By barnali in forum 3.x Legacy Premium Help
    Replies: 2
    Last Post: Mar 04, 2015, 7:23 AM
  2. Replies: 2
    Last Post: Feb 04, 2014, 7:44 AM
  3. VBox + FieldContainer -> controls disappears
    By Zdenek in forum 2.x Help
    Replies: 1
    Last Post: Jan 03, 2014, 1:03 PM
  4. [CLOSED] [1.0] ComboBox and VBox
    By Timothy in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Dec 28, 2010, 7:45 PM
  5. [CLOSED] [1.0] HtmlEditor and VBox
    By Timothy in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Dec 28, 2010, 7:40 PM

Posting Permissions