question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Descriptions Component does not support dynamic Description collection

See original GitHub issue

Describe the bug

the dynamic collection does not work!

Steps to reproduce (please include code)

basic idea:

<Descriptions Title="User Info">
    <DescriptionsItem Title="UserName">Zhou Maomao</DescriptionsItem>
    <DescriptionsItem Title="Telephone">18100000000</DescriptionsItem>
    <DescriptionsItem Title="Live">Hangzhou, Zhejiang</DescriptionsItem>
    @if(showAdvance){
      <DescriptionsItem Title="Remark">Empty</DescriptionsItem>
      <DescriptionsItem Title="Address">
          No. 18, Wantang Road, Xihu District, Hangzhou, Zhejiang, China
      </DescriptionsItem>
     }
</Descriptions>
<button @onclick="@(()=>showAdvance=!showAdvance)" >switch mode</button>

private bool showAdvance=false;
@code{
}

Exceptions (if any)

n.a

Further technical details

AntDesign v0.15.1

ref:

https://antblazor.com/zh-CN/components/descriptions

Issue Analytics

  • State:open
  • Created 3 months ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
congzhangzhcommented, Jul 1, 2023

unless blazor provides something like OnBeforeRender/override StateChanged, there is no perfect solution, as the item init/dispose happens too later, which will cause Descriptions to use old items data.

on another side, the preparematrix is really just something about render internal, not related to the logical part, call before StateChanged internal is perfect

ref:

  1. https://github.com/dotnet/blazor/pull/1716#issuecomment-446950792
  2. https://chrissainty.com/understanding-cascading-values-and-cascading-parameters/
  3. https://blazor-university.com/components/component-lifecycles/images/component-lifecycle-1.jpg
0reactions
congzhangzhcommented, Jun 30, 2023

I’m not sure if the render fragment will work, maybe it will reproduce the initialization logic when the render is refreshed.

you are right, it does not work! error as before!

@page "/counter"

<PageTitle>Counter</PageTitle>

<h1>Counter</h1>

<p role="status">Current count: @currentCount</p>

<button class="btn btn-primary" @onclick="IncrementCount">Click me</button>

<Descriptions Title="@(currentCount.ToString())">
    
    @GenDescriptions()
    
</Descriptions>
<button @onclick="@(()=> { showAdvance = !showAdvance; currentCount++;})" >switch mode</button>
@currentCount <br/>
@showAdvance
@code {
    private int currentCount = 0;

    RenderFragment GenDescriptions() => @<text><DescriptionsItem Title="UserName">Zhou Maomao</DescriptionsItem>
                                            <DescriptionsItem Title="Telephone">18100000000</DescriptionsItem>
                                            <DescriptionsItem Title="Live">Hangzhou, Zhejiang</DescriptionsItem>
                                            @if (showAdvance)
                                            {
                                                <DescriptionsItem Title="Remark">Empty</DescriptionsItem>
                                                <DescriptionsItem Title="Address">
                                                    No. 18, Wantang Road, Xihu District, Hangzhou, Zhejiang, China
                                                </DescriptionsItem>
                                            }</text>;
    private bool showAdvance=false;
    private void IncrementCount()
    {
        currentCount++;
    }
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

Add Dynamic Descriptions to Customize the Editor | Blog
You can configure descriptions on fields, collections and globals. All the description properties support three types: String; Function ...
Read more >
Adding Dynamic Descriptions Based on Selection
Adding Dynamic Descriptions Based on Selection ... Make sure that the "Target Filters" option is set to All Fields. Click OK. Click OK....
Read more >
Structure and style Collection pages
However, unlike static pages settings, Collection page settings can have dynamic values, meaning they result in unique information for each Collection item page ......
Read more >
Component Models
All models should provide both static and dynamic descriptions. A model should not be considered complete without both descriptions. The dynamic description of ......
Read more >
Developing Applications with Oracle Visual Builder in ...
Visual Builder gives you access to a rich set of UI components to build your page, from static ones like heading and avatar...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found