[CLOSED] PanelTagHelper.Collapsed doesn't work

  1. #1

    [CLOSED] PanelTagHelper.Collapsed doesn't work

    Hello!
    I'm facing a problem when I try to render an accordion's panel when the first panel needs to be collapsed.

    I found the collapsed tag helper and its description make me think it is the right one, but it doesn't work.

    Look at this sample:

    PanelCollapsed.cshtml
    @page
    @model ExtCookbook.Pages.PanelCollapsed
    @{
    }
    <ext-section target="Main">
        <ext-container region="Center" scrollable="true" paddingAsString="30 20 30 50" layout="Accordion">
            <items>
                <ext-panel title="Collapsed" collapsed="true">
                    <items>
    
                        <ext-button variant="Light"
                                    scale="Medium"
                                    marginAsString="5 0 0 0"
                                    style="width: 100%"
                                    text="hello"
                                    hrefTarget=""
                                    textAlign="Left"
                                    iconAlign="Left"
                                    cls="sidebar-nav-link"
                                    iconCls="x-md save" />
    
                    </items>
                </ext-panel>
                <ext-panel title="Expanded" collapsed="false">
                    <items>
    
                        <ext-button variant="Light"
                                    scale="Medium"
                                    marginAsString="5 0 0 0"
                                    style="width: 100%"
                                    text="hello"
                                    hrefTarget=""
                                    textAlign="Left"
                                    iconAlign="Left"
                                    cls="sidebar-nav-link"
                                    iconCls="x-md save" />
    
                    </items>
                </ext-panel>
            </items>
        </ext-container>
    </ext-section>
    PanelCollapsed.cshtml.cs
    using Microsoft.AspNetCore.Mvc.RazorPages;
    
    namespace ExtCookbook.Pages
    {
        public class PanelCollapsed : PageModel
        {
            public void OnGet()
            {
            }
        }
    }
    Is this the correct way?
    Thank you
  2. #2
    Hello, bbros!

    It looks like you are doing it right! But as the default of collapsed is false, then Ext.NET does not explicitly tell the second panel's collapsed state should be false.

    You should be able to force specify the value as false if you change your view code line 24 to:

    <ext-panel title="Expanded" x:raw-collapsed="false">
    Let us know if it doesn't help and I'll check other options here.

    EDIT: amazing how I could read the right syntax in the original GitHub issue documenting the feature, yet write it incorrectly here. Fixed x:raw-collapsed above.
    Last edited by fabricio.murta; May 12, 2021 at 4:55 PM.
  3. #3
    Thank you!

    I suppose that the correct instruction is:
    <ext-panel title="Expanded" x:raw-collapsed="false">
    But how can i pass a parameter to that?
    The following example doesn't work:
    @{ 
     var closed = false;
    }
    <ext-panel title="Expanded" x:raw-collapsed="@closed">
    Even with string doesn't work:
    @{ 
     var closed = "false";
    }
    <ext-panel title="Expanded" x:raw-collapsed="@closed">
    This is the only way?
    @{ 
     var closed = false;
    
     if (closed){
        <ext-panel title="Expanded" x:raw-collapsed="true" />
     }else{
        <ext-panel title="Expanded" x:raw-collapsed="false" />
     }
    }
  4. #4
    Hello again, bbros!

    To use complex logic to decide the value of an inlined custom config, you should go to the model variant.

    Here's a summary of the inline custom config syntaxes currently supported in most components:

    - String
    x-collapsed="false"

    This outputs the setting in JavaScript as:

    collapsed: "false"

    - Constant/primitive
    x:raw-collapsed="false"

    This outputs the setting in JavaScript as:

    collapsed: false

    - Complex/model
    x:model-collapsed="current_position++ != expanded_panel_pos"

    This outputs the setting in JavaScript as:

    collapsed: false (or true, depending on how the expression is evaluated!)

    Before I start repeating myself too much, please refer to this post for other syntaxes:
    - CellEditingPlugin Edit event over CheckColumn (here you, yourself, use it correctly in "code behind"/model) :-)
    - Post #6 in GridPanel Boolean data and Checkbox editor (covering the above and other two other syntax concepts, block and model/"code behind")
    - Post #2 in EXT Grid panel grid filters - EXT.net Classic v 7.2 (even more on the CustomConfig block)

    Last, but not least, a transcript of your code sample using the x:model- concept:

    @page
    @model ExtCookbook.Pages.PanelCollapsed
    @{
        var current_position = 0;
        var expanded_panel_pos = 1;
    }
    
    <ext-section target="Main">
        <ext-container region="Center" scrollable="true" paddingAsString="30 20 30 50" layout="Accordion">
            <items>
                <ext-panel title="Collapsed" x:model-collapsed="current_position++ != expanded_panel_pos">
                    <items>
                        <ext-button text="hello" />
                    </items>
                </ext-panel>
                <ext-panel title="Expanded" x:model-collapsed="current_position++ != expanded_panel_pos">
                    <items>
                        <ext-button text="hello" />
                    </items>
                </ext-panel>
            </items>
        </ext-container>
    </ext-section>
    The model code is the exact same as you provided. Thanks for sharing it by the way, even if empty, ensures nothing was left behind!

    Hope this helps!
    Fabrício Murta
    Developer & Support Expert

Similar Threads

  1. Collapsed panel header onmouseover no work
    By necpoctt in forum 2.x Help
    Replies: 1
    Last Post: Dec 25, 2013, 7:59 AM
  2. Replies: 1
    Last Post: Jan 26, 2011, 3:07 PM
  3. tabpanel doesn't work in IE8
    By maryam in forum 1.x Help
    Replies: 3
    Last Post: Aug 18, 2010, 5:49 AM
  4. Replies: 8
    Last Post: Jun 28, 2010, 8:20 AM
  5. Keymap doesn't work
    By Kamal in forum 1.x Help
    Replies: 2
    Last Post: Aug 13, 2009, 10:49 AM

Posting Permissions