[CLOSED] Content vrs Items

  1. #1

    [CLOSED] Content vrs Items

    Support,

    When using a BorderLayout, i have historically always used <Items> for all the panels in my layout.

    However, i want to create a control (ascx) to hold a South panel so i can reuse it in all my pages as needed.

    I found that it impossible to cleanly add this control to my Items without first creating a parent container with "Content"
    <ext:Panel runat="server" Layout="Border">
                <Items>
                    <ext:Panel runat="server" Title="Tab 1" Region="North" />
                    <ext:Panel runat="server" Title="Tab 2" Region="South">
                       <Content>                       
                            <uc:TestUC runat="server" />
                        </Content>
                    </ext:Panel>
                </Items>
           </ext:Panel>
    It seems that it works well if i remove the "Items" and only have a "Content" in my parent container.

    <ext:Panel runat="server" Layout="Border">
                <Content>
                    <ext:Panel runat="server" Title="Tab 1" Region="North" />
                     <uc:TestUC runat="server" />
                </Content>
           </ext:Panel>
    Are there any drawbacks to this?

    thanks,
    /Z
  2. #2
    Hello @Z!

    Layouts with <Content /> blocks have some unavoidable issues, unfortunately. This is generally speaking. Because layouts govern the container's inner components. If you wrap it in <Content /> then in some circumstances the layout propagation does not make it to the inner components.

    So, use this with care. If you search forums you'll see a number of issues people raised. They are not really bugs, because the Content blocks adds the freedom to insert any HTML code within so that will ultimately simply not reference to Ext.NET components' theming/css rules and the layout distribution goes beyond Ext.NET components' boundaries of domain.

    I think this is an interesting topic to understand the limitations, and that at least part of them were introduced over the course of Ext.NET development. As theming became more elaborate, some scenarios that worked in very early versions stopped working on recent ones. Notably between Ext.NET 1 and 2: What is the 4.2 version of the fix for this Old Forum Post.

    I hope this answers well your inquiry, as I read it I instantly remembered this discussion so maybe I diverged from the point you were trying to question here.
    Fabrício Murta
    Developer & Support Expert
  3. #3
    Understood.

    However, I need the same grid added to 4 different pages as a South panel. I wanted to use a control for reusability.

    How can I achieve some code reusability and stay within ext.net <Items> without copy/pasting my GridPanel 4 times?

    Thxs
    /Z
  4. #4
    Hello @Z!

    I believe the best way for code reusability would be by extending the class itself, I mean, making a component and overriding the defaults with the contents you usually use and want to be common. This way you can add the component within the <Items> tags, because they will inherit from Ext.Net.ComponentBase. Using as .ascx pages inherently requires you the Content blocks, which comes with this layout possible drawbacks.

    But this does not mean you shouldn't use layouts. You can ensure the immediate surroundings of the outer html of the component fits to the inner of the containers you are adding the custom control in, and just watch out for the edge cases where layout does not fit well.

    In other words, depending on how you want to use the grid across the pages you can just go with the Content approach.
    Fabrício Murta
    Developer & Support Expert
  5. #5
    About the C# class extending, there are some interesting topics that may be just what you want:

    - How to extend Ext.NET components
    - Extending a base component in order to provide custom Direct Events - some questions

    They are quite old, for Ext.NET 1, but should be quite accurate nevertheless, as you'll have intellisense by your side while extending the classes.

    The second topic above shows extensions in both client-side (javascript) and server-side (C# class).

    Hope this helps.
    Fabrício Murta
    Developer & Support Expert
  6. #6
    thanks. The borderlayout has only center and south (control) and i dont see any issues using Content so i will take that route for now. i can always make a control or copy/paste it if needed
    thanks,
    /Z

Similar Threads

  1. Replies: 14
    Last Post: Dec 09, 2013, 11:42 AM
  2. [CLOSED] Mixing Container Items and Content
    By sisa in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Aug 23, 2012, 1:05 PM
  3. [CLOSED] Question about order of <content> and <items>
    By rosua in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Apr 12, 2012, 4:56 AM
  4. Replies: 6
    Last Post: Aug 13, 2010, 8:27 AM
  5. Items vs Content
    By igitur in forum 1.x Help
    Replies: 1
    Last Post: Jul 13, 2010, 10:40 AM

Posting Permissions