Serenity: Dynamic Navigation refresh

Created on 9 Jan 2018  路  5Comments  路  Source: serenity-is/Serenity

Hi,

This is for anyone who could answer this...

I've read all the issues pertaining to this, but nothing seems to work. I've successfully created dynamic menu items, but I can't seem to get them to refresh after a save. Any hints as to how to regenerate the menu when needed would be appreciated.

Cheers

Most helpful comment

Hi @Estrusco and thanks for the help.

I added the lines

            protected override void AfterSave()
            {
                base.AfterSave();
                TwoLevelCache.ExpireGroupItems(Administration.Entities.UserPermissionRow.Fields.GenerationKey); TwoLevelCache.Remove("NavigationHelper:NavigationItems");
            }

to my Save handler and the same to the delete handler and also added

window.location.reload(false);

after the return from the service. There's probably a more elegant way to refresh but this will do for now. If I come up with it (probably around a jQuery load on the div), I'll update the post,

For the moment, thanks a lot!

All 5 comments

The items in menu are chached. You have to invalidate chache when you modify item list.

Try with some like

TwoLevelCache.ExpireGroupItems(Entities.UserPermissionRow.Fields.GenerationKey);
TwoLevelCache.Remove("NavigationHelper:NavigationItems");

or

TwoLevelCache.ExpireGroupItems(Entities.UserPermissionRow.Fields.GenerationKey);
TwoLevelCache.Remove("LeftNavigationModel:NavigationItems");

Thanks. I've been experimenting with removing the cache but so far no success. However, I didn't use the ExpireGroupItems. Thanks!

Hi @Estrusco and thanks for the help.

I added the lines

            protected override void AfterSave()
            {
                base.AfterSave();
                TwoLevelCache.ExpireGroupItems(Administration.Entities.UserPermissionRow.Fields.GenerationKey); TwoLevelCache.Remove("NavigationHelper:NavigationItems");
            }

to my Save handler and the same to the delete handler and also added

window.location.reload(false);

after the return from the service. There's probably a more elegant way to refresh but this will do for now. If I come up with it (probably around a jQuery load on the div), I'll update the post,

For the moment, thanks a lot!

Hi @karimhyatt ,

I wrote your code, but putting "window.location.reload(false)" on dialogtemplate (this is the form who I expected refresh the menu with your own items) and after reload, NavigationModel() reload the GetNavigationItems backing to the natural menu.

What can I do for keep the new menu on memory?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Pinellus picture Pinellus  路  3Comments

dudeman972 picture dudeman972  路  3Comments

AmuthaKondusamy picture AmuthaKondusamy  路  3Comments

Akarsh03 picture Akarsh03  路  3Comments

StefanTheiner picture StefanTheiner  路  3Comments