$sp.getWidget is working only once while using Data table widget

Abhishek B2
Tera Contributor

Hey there,

I am trying to add filter to list widget, where on selecting of incident record, I will show that record in list widget. This works when I select a record for the first time[Image 1], but doesn't work if I select other record[Image 2]. 

I don't know if there is a limitation on calling 'widget-data-table' widget, as I have tried this approach with form widget and works perfectly fine. 

I have checked that widget option is updated when server is called again. But, output of $sp.getWidget doesn't contain necessary data.

Image 1:

Portal.jpg

Image 2:

Portal2.jpg

 

Thank!

1 ACCEPTED SOLUTION

Michael Jones -
Giga Sage

I've noticed this happens with embedded widgets - they just don't refresh with the rest of the client data model the way you would expect. I usually have to play around quite a bit to get them working right, but try something like this: 

Wrap your <sp-widget> inside of a div with an ng-if="wid.data.widgetInstance" condition. 

Then, in your client script, at the start of $scope.callList, set $scope.wid = '';

 

This should have the effect of triggering the condition on the div to "destroy" the embedded widget when you select a new incident and then recreate it once you get the response. 

I hope this helps!
Michael D. Jones
Proud member of the GlideFast Consulting Team!

View solution in original post

2 REPLIES 2

Michael Jones -
Giga Sage

I've noticed this happens with embedded widgets - they just don't refresh with the rest of the client data model the way you would expect. I usually have to play around quite a bit to get them working right, but try something like this: 

Wrap your <sp-widget> inside of a div with an ng-if="wid.data.widgetInstance" condition. 

Then, in your client script, at the start of $scope.callList, set $scope.wid = '';

 

This should have the effect of triggering the condition on the div to "destroy" the embedded widget when you select a new incident and then recreate it once you get the response. 

I hope this helps!
Michael D. Jones
Proud member of the GlideFast Consulting Team!

zue
Tera Contributor

Great answer! Specially the tip to wrap <sp-widget> inside a div with an ng-if condition.

Setting the ng-if within the <sp-widget> (<sp-widget ng-if="...">) does not destroy the widget!

THX