This is a migrated thread and some comments may be shown as answers.

Page is not re-rendering after URL parameter changed

9 Answers 2449 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
const
Top achievements
Rank 2
Veteran
const asked on 17 Jun 2020, 03:03 PM

Hi,

I'm using  "nav-link" to go to page:

@page "/orders"

I'm also using Parameter which tells me what type of order to be loaded with that Page:

@page "/orders/{ord}"

 

There is "nav-item" dropdown on NavMenu.razor page to navigate to Page:

                <a class="dropdown-item" href="orders/SO">SO</a>
                <a class="dropdown-item" href="orders/PO">PO</a>

 

The issue is, when I click on any of those links first time (say href="orders/SO") - the Page loads correctly.

But then, when I click on href="orders/PO" - the page isn't rendering accordingly even though Parameter on Url has changed.

This happens after I replaced JS Table I used before with Telerik Grid.

Please advise

 

9 Answers, 1 is accepted

Sort by
0
Marin Bratanov
Telerik team
answered on 17 Jun 2020, 03:57 PM

Hello,

I am attaching a sample I made for you that shows how you can use the OnParametersSet event to capture parameter change (inlcuding one coming from route parameters). It has a grid whose data changes to reflect the router parameter.

If this does not help you solve this, please modify it to showcase the Telerik issue you're facing so I can have a look.

 

Regards,
Marin Bratanov
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
0
const
Top achievements
Rank 2
Veteran
answered on 17 Jun 2020, 05:04 PM

Looks like solution you are offering works for me (will test it more intensively later).

May I know what's causing the issue?

Even this doesn't work:

    protected override async Task OnParametersSetAsync()
    {
    StateHasChanged();
    }

Please advise.

0
Marin Bratanov
Telerik team
answered on 18 Jun 2020, 05:57 AM

Hi,

What happens would heavily depend on the code you have, but if the parameters change and other parts of the view update, perhaps the issue is with the grid's Data reference - it would ether have to be an ObservableCollection where you can add/remove/clear, or you need a new reference, see the following article for more details and examples: https://docs.telerik.com/blazor-ui/knowledge-base/grid-force-refresh

 

Regards,
Marin Bratanov
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
0
const
Top achievements
Rank 2
Veteran
answered on 18 Jun 2020, 01:57 PM

Just FYI.

This issue is rather Telerik.Blazor  than Telerik.Blazor.Grid one, I think.

I have another page where I had exactly the same issue with DatePicker (DP).

Until I used JS DP - the routing with parameter worked fine.

But once I replaced JS DP with Telerik one - the issue appeared.

 

Your suggestion to use OnParameterChange event instead OnInitializedAsync one bypassing the issue but not resolving one.

 

Looks like Blazor knows that parameter was changed (otherwise OnParameterChange wouldn't work) but something stops or interferes him fire OnInitializedAsync to render the Page.

Thoughts?

0
Accepted
Marin Bratanov
Telerik team
answered on 18 Jun 2020, 01:59 PM

My though is that whatever JS widget you had did always re-initialize (e.g., by hooking to OnParametersSet or OnAfterRender) which is not a good practice. In a real Blazor component, the field references are more important and they may need to change for a UI update to trigger.

At this point I'm still guessing because I have not seen the code that causes a problem with the Telerik components and the approach I showed with the grid is a valid one - navigating between the same component with different route parameter may not re-initialize it, so its OnInitialized event may not fire, but OnParametersSet will.

So, if you see a Telerik issue, please open a ticket or post here the minimum viable reproducible (e.g. ,based on my sample) so I can have a look.

 

Regards,
Marin Bratanov
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
0
const
Top achievements
Rank 2
Veteran
answered on 18 Jun 2020, 02:15 PM

Ok, Martin, I'll create simple demo project and provide you with one.

Thank you for discussion

0
const
Top achievements
Rank 2
Veteran
answered on 18 Jun 2020, 02:16 PM
sorry, Marin, not Martin of course, my bad...
0
Marin Bratanov
Telerik team
answered on 18 Jun 2020, 02:18 PM

No worries, everyone gets my name as Martin with a "t" :)

I'll be looking forward to your findings. Perhaps there is a bug, and if so - I want to find it so we can have the chance to fix it.

 

Regards,
Marin Bratanov
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
0
const
Top achievements
Rank 2
Veteran
answered on 18 Jun 2020, 02:19 PM
Great, sound like a plan!
Tags
General Discussions
Asked by
const
Top achievements
Rank 2
Veteran
Answers by
Marin Bratanov
Telerik team
const
Top achievements
Rank 2
Veteran
Share this question
or