Lifecycle pageproperty

Hi Radzen,

I'm using a custom method to retrieve some user info per page ( while there is no secure alternative for global variables or objects that can be accessed across pages ).

I've noticed that the object retrieved from this custom method ( similar like the UserPersonData from radzen demo / examples ). has a short lifecycle .

Explaining: Accessing the values of the object returned from the custom method can be accessed and used within the invoke if then structure and gets lost if used outside the invoke in the next statement or DataGrd filter .

does this seems familiar ? or could it be that the page has to many properties and can only hold a limited number of properties ?

So using this property object a second time gives an "can not get value from undefined" erros.

There is no limitation of the number of page properties and also there is no life cycle. Once a page property is initialized (via Set property action) it will remain for as long as the page is active (e.g. the user does not navigate away).

How does your code which sets the property looks like? And how does the other action which uses it (and leads to cannot get value from undefined) look like?

I'm setting the page property after invoking the custom method like:

image

Than I'm using this "curGidId" or the "soUser property elsewhere .

I have created curGidId to look if it something was like not able to get the property"." itemvalue .

So using it in an other invoke or filter of a datagrid:

So :like below works:

if the 33.1.2 Invoke is outside the 33 Invoke , it does not work.

I can send you the needed files

I think I know why this happens. The UserPersonalData executes asynchronously and the code after it will run before the Then event is executed. If you need to use the properties set in the Then event then the code which uses them should be in the same Then event. Alternatively set the Condition of the getFinRunDefinities to ${soUser}. It will then execute only if soUser is set.

the execution async would explain things .. but I was thinking , that a callLoadData() , would wait for the page load to finish ?

Any global variable / object availability in Angular 11 ?
I have to include the GidId ( Global Identification ID of the user ) on each page now .. and almost all the tables have this GidId .. Just repeating the code on each page seems not that ideal.

Check this thread: Set global property

Well ...
That is a security issue : You can easily change the local storage and it holds only string values .
I have looked into the form about this and did not help me .
I have to look into switching to Blazor, but the application has grown now in the two years .. if there was a easy or even an helper to convert from the angular Radzen to Blazor .. :frowning:

Would this fit in tho Radzen ways..

It will but you will have to use the code generation ignore list to import the global constants class where you need it.

Actually if you use the *.component.ts file you don't need to use the ignore list - that file can be edited by the user freely. You will then need to cast this to any and assign the property with Execute code

(<any>this).globalConstants.myProperty = value

Thank you , have to try this, looks interesting if it works as expected .
But incorporating it in the standard Radzen an option ?

Hi @korchev ,

I'm not (yet) a complete Angular hero, could you explain.

I'm not looking into an solution where the global variables are loaded on application start ( login , user authenticated and retrieve the user / application settings from database and set the global variables once ).
I'm not looking for a solutions where we would have to paste same code in each *.component.ts ( or page).

Ergo: If I would have a database table where I would store the user / application settings, and invoke a database method. on each page to retrieve the desired setting voor the page / user / application.

How would a page load event look like .

Do I have to do all page load actions like setting a page property etc. after the Then of this database method invoke .. ?

To adapt this in an existing application it would take some time to change each page because there is no "re" positioning and moving parts of the code in an event in Radzen designer ( would improve productivity a lot .. ) . Sharing some thoughts .

Yes, this is what Radzen currently provides out of the box.