views:

63

answers:

1

Hi, guys :)

Sorry for not very clear question title, but maybe image will help to describe my ploblem:

image

I want small child panels in parent panel to be autosizeable. Here is my markup and codebehind:

    protected void Page_Load(object sender, EventArgs e)
        {
            var bkg = new[] { "background-color: wheat;", "background-color: gray;", "background-color: #AAAAAA;" };
            var random = new Random();
            for (var i = 0; i < 285; i++)
            {
                var panel = new Panel
                                {
                                    Header = false,
                                    Width = 60,
                                    Height = 30,
                                    BodyStyle = bkg[random.Next(0, 3)],
                                    Frame = false,
                                    StyleSpec = "padding-top: 1px; padding-left: 1px;",
                                    ID = "panel_" + i,
                                    Html = string.Format("<span class='x-unselectable'>{0}</span>", i)
                                };
                var cell = new Cell();
                cell.Items.Add(panel);
                TableLayout1.Cells.Add(cell);
            }

        }

<ext:Panel ID="pnlWorkArea" runat="server" Title="Test">
    <Body>
        <ext:TableLayout ID="TableLayout1" runat="server" Columns="15">
        </ext:TableLayout>
    </Body>
</ext:Panel>
+1  A: 

If you mean that you want the child panel arrangement to completely fill the center region, there's not a simple way to do that other than calculating the inner dimensions of the region, then assigning fixed height/width to the child panels as you are now, but based on your measurements. You could do this either by handling the render event or overriding onRender of the center region panel.

If the number of rows and columns is always the same you could try using % dimenstions, but in my experience that does not work consistently across browsers (you can get small gaps sometimes due to rounding from decimal percentages to pixels).

bmoeskau
I've tried %, but this works not as I expected ;(
Tror