Page 1 of 1

Hide partial JSON response array

Posted: Sun Apr 27, 2014 4:19 pm
by John6122514

I have a JSON service array tied to a grid, with in the grid I have a Select component. The service response has two set of arrays. The first array sends a list of titles for the next array which sends the results for each title. Below is an example of what the array would return. I have the first array setup to the grid, and the second array setup to the Select component. It works fine, I get 5 different select fields with all the correct results. But I want to only show Category and hide the rest of the results. Can this be done?
Country
---USA
State
---California
City
---Los Angeles
CategoryType
---Attractions
---Zoos
---Other
Category
---Sports
---Concerts
---Beaches
---Walking


Hide partial JSON response array

Posted: Sun Apr 27, 2014 10:25 pm
by Alena Prykhodko

Hi John,

To modify your service response you need to use "generic security context" and use it with your service.

1 Create custom security context service http://docs.appery.io/documentation/g...

2 Use next code to wrap answer and make custom logic (including server requests).
pre

Appery.MySecurityGeneric = Appery.createClass(SecurityContext, {

Code: Select all

 invoke: function(service, settings) { 
     var oldSuccess = settings.success; 

     var onSuccess = function(value, other){ 

         //here you need to change your response stored in the value. 
         //value.hello = "world"//That's an example. 
         //To see what stored in the value variable please use following code: 
         console.log("value = "); 
         console.log(value); 

         oldSuccess.call(this, value, other); 
     }; 

     settings.success = onSuccess; 
     Appery.MySecurityGeneric.$super.invoke.call(this, service, settings); 
 } 

});
/pre
Note: you should replace "MySecurityGeneric" with your security generic context name.

  1. After you create generic security context please use this context in your service.
    Image