Why data.variable not displaying data in widget?

Ankita Kolhe
Tera Contributor

Hi Community,

 

I have two widgets, in which first widget contains text box & search button. When user clicks on Search button, the another widget displays table.

But data is not displaying on table.It seems some issue with - data.gisid & data.location.

However, logs are displaying correctly.

 

AnkitaKolhe_0-1705908979244.png

 

 

 

Widget 1 html code:-

<span class="col-md-7"><input id="search_term" name="search_term" type="search" placeholder="Enter Name,GIS ID or DUNS" class="form-control input-md"></span> 

<div class="each-pill" ng-class="{'active':c.selectedPill == 'entitytable'}" ng-click="selectPill('entitytable')">

<a type="button" ng-click="c.searchEntityREST()" class="btn btn-primary">${Search Entity}</a>

</div>

 

Widget 2:-

 

Html code:-

<table class="table table-striped">
<thead>
<tr>
<th>GIS Entity ID</th>
<th>Entity Name</th>
<th>Entity Location</th>
<th>Entity Type</th>
</tr>
</thead>
<tbody>
<tr ng-if="data.gisid!='"> 
<td>{{data.gisid}}</td>
<td>{{data.location}}</td>
</tr>
</tbody>
</table>

 

Server Script:-

 

(function() {
    /* populate the 'data' object */
    /* e.g., data.table = $sp.getValue('table'); */

    var arr = [];

    if (input && input.action == "callSearchEntity") {

        gs.info('arr');
        gs.info('test server side');
        gs.info('input: ' + input.search_term);
        var dat = new x_kpm79_kpmgi_cto.CTOEntityManagementUtils().triggerRESTMessage('global.sentinel''GetEMEntities', input.search_term);
        gs.info('returned dat: ' + dat);
        arr = dat.split(',');
        gs.info('arr[0]: ' + arr[0]);
        gs.info('arr[1]: ' + arr[1]);

    }
    data.gisid = arr[0];
    data.location = arr[1];
   
     gs.info('arr[0] out: ' + arr[0]);
     gs.info('arr[1] out: ' + arr[1]);

})();
 
Client Script:-
 
api.controller=function(spUtil,$scope,spModal,$timeout) {
   
    /* widget controller */
    var c = this;

    $scope.showWidget = "";

  $scope.$on('showHideWidget'function(event,d,obj) {

  $timeout(function(){

    c.server.get({
            action:"callSearchEntity",
            search_term:obj.search_term,
            //country:document.getElementById('country').value
        });
    alert(obj.search_term);
  $scope.showWidget = d;

  });

  });

};
 
logs:-
AnkitaKolhe_1-1705908979256.png

 

 

 
Could anyone please help on this?
5 REPLIES 5

_Gaurav
Kilo Sage

Hi @Ankita Kolhe 
Sometimes this happens, could you please try to convert it to the STRING before passing it to the HTML

data.gisid = arr[0].toString();

data.location = arr[1].toString();



Please hit helpful if this resolves your issue.
Thanks

Hi @Ankita Kolhe  please let me know if this works?

Joe B2
Giga Guru

Typically when referring to data directly from the server script I would prefix it with c (based on the c = this line in the client script)

<td>{{c.data.gisid}}</td>
<td>{{c.data.location}}</td

Unsure if this helps.

 

Still not working.