Page 2 of 2

Best way to filter collection queries

Posted: Thu Feb 26, 2015 3:06 am
by Colten Tenney

So just to confirm Yurii, I need to use a generic security context and implement server code?

I created a generic security context and went into the settings for my query service and selected the security context I created for the Security context field. However I haven't worked with security contexts before so my implementation code is just
pre
$t.Multilevel = $t.createClass(SecurityContext, {
invoke: function(service, settings) {
//Do any logic before call
$t.Multilevel.$super.invoke.call(this, service, settings);
//Do any logic after call
}
});
/pre
Does this code require any logic? And how do I change the response to multilevel?

Your help is much appreciated.


Best way to filter collection queries

Posted: Fri Feb 27, 2015 4:38 am
by Yurii Orishchuk

Hi Colten,

pre

So just to confirm Yurii, I need to use a generic security context and implement server code?

/pre

Nope - you need to choose one of these options.

It's better for your to use server code instead of security context.

Please pass following tutorial to understand how it works: http://devcenter.appery.io/tutorials/...

Also you can find more details about server code here:
http://devcenter.appery.io/documentat...

As a conclusion - this server code should return multilevel JSON that will reflect to multilevel components lists/collapsible/grids..

Regards.


Best way to filter collection queries

Posted: Fri Feb 27, 2015 8:36 pm
by Colten Tenney

Thanks for the info Yurii,
I read all the documentation on server code on the appery website. Your previous example however is a bit confusing to me. My database is set up like the following Image
As you can see a single 'deal' encompasses data from multiple lines, and is not a single column.

My starter code for the server code is the following
pre
var DB_id = "53cxxxx78c4b8db4d5" ;
var collectionName = "DealCollection";

var query = [];

query = Collection.query( DB_id , collectionName);

var result = [];

for( var i = 0 ; i < query&#46;length ; i++) {
result&#46;push ( {Location:query&#46;LocationID, id:query&#46;id });
}
response&#46;success(result);
/pre

I am assuming I will need more loops and possibly more arrays to form the correct response. The whole aim of doing this is to have only one call to the server to get all the information rather than setting up a different collection for each location and having a call for each location.


Best way to filter collection queries

Posted: Sun Mar 01, 2015 9:23 pm
by Colten Tenney

So just to follow up, I created the correct response via server code. I had to put my collapsible blocks in a grid, now everything appears to work just fine.

Here you can see a test response
Image
Here is the successful server code for anyone interested
Image


Best way to filter collection queries

Posted: Mon Mar 02, 2015 11:12 am
by Evgene Karachevtsev

Hello Colten,

Thank you for the update.