The CreatorCon Call for Content is officially open! Get started here.

Refreshing a widget/ clearing widget data based on another variable in form

SatheeshKumar
Kilo Sage

Hi,

I need to Refresh a widget/ clearing widget data when another variable in form changes. did anyone faced the same situation??

Thanks,

Satheesh

1 ACCEPTED SOLUTION

Deepak Ingale1
Mega Sage

Hi,

 

1) You can use $sp.page.g_form to get variable values in widget

2) You need to use $watch controller method to keep an eye of variable change ( this is like event in DOM, when variable changes, $watch senses it )

3) Once you get this event fired for variable in step 1, you can reset the data variable object in client controller script.

 

Please see below link $watch usage to check how you can use $watch to keep a track of variable value change.

View solution in original post

4 REPLIES 4

SanjivMeher
Kilo Patron
Kilo Patron

Can you elaborate more or provide screenshots?


Please mark this response as correct or helpful if it assisted you with your question.

Deepak Ingale1
Mega Sage

Hi,

 

1) You can use $sp.page.g_form to get variable values in widget

2) You need to use $watch controller method to keep an eye of variable change ( this is like event in DOM, when variable changes, $watch senses it )

3) Once you get this event fired for variable in step 1, you can reset the data variable object in client controller script.

 

Please see below link $watch usage to check how you can use $watch to keep a track of variable value change.

Vijay Pawar3
Tera Contributor

Hello Satheesh,

        In HTML part of widget add onchange event on the field to call a function in client controller. In this function you can add logic tp refresh the data (hope its data object). If you need to update the data objects with new values based on the variable changed, use one of the following methods .

 

this.server.get() : Calls the Server Script and passes custom input.

this.server.update() : Calls the server and posts this.data to the Server Script.

this.server.refresh() : Calls the server and automatically replaces the current options and data from the server response.

you can user input/data object to send changed variable to server script.

Deepak Ingale1
Mega Sage

Could you please mark response as correct and close the thread?