refresh the widget data based on button click

caffry
Kilo Guru

once i click on a button i need to refresh the widget.

i tried with 

   $timeout(function(){


spUtil.update($scope);



}, 1000);

Stilll the list of records are not refreshed

2 REPLIES 2

vkachineni
Kilo Sage
Kilo Sage

Your HTML should have a button click event handler.

<div>
<!-- your widget template -->
  <button id="btn-alert" ng-click="c.onAlert()" class="btn btn-default">
    Alert
  </button>
</div>

Your client script should have a function defined

var c = this;
    c.onAlert = function() {

    c.data.action = 'update';
    c.server.update().then(function(response) {

    c.data.action = ''; //clear the action
    });
}

Your Server script should respond to the action

if(input && input.action == 'update')
{
  //handle the button click
  console.log(JSON.stringify(input));
	
}

 

Please mark Correct and click the Thumb up if my answer helps you resolve your issue. Thanks!
Vinod Kumar Kachineni
Community Rising Star 2022

vkachineni
Kilo Sage
Kilo Sage

Also what was the out come of the questions on the issue with data.final = vale; that you asked previously.

Can't find the questions.

Please mark Correct and click the Thumb up if my answer helps you resolve your issue. Thanks!
Vinod Kumar Kachineni
Community Rising Star 2022