Page 1 of 2

Best way to filter collection queries

Posted: Mon Feb 23, 2015 6:14 pm
by Colten Tenney

Hi,
I currently have a collection with 'deals', and each deal includes the properties, Date and LocationID. I have a page with a date picker that picks a date and invokes the query. I use a where clause (via javascript in the where return value in the mapping) to get only the 'deals' with the correct date. This part works fine.

The deals are listed in a list that is nested within a collapsible block. There are multiple collapsible blocks each representing a location. I need to somehow sort all the deals that I get with the correct date to their corresponding list/collapsible block based on their LocationID. What is the best way to do this?

I've attached a screenshot of the page. Currently I've only implemented one collapsible block, so all deals in the collection go there. Image


Best way to filter collection queries

Posted: Mon Feb 23, 2015 9:29 pm
by Evgene Karachevtsev

Hello!

Could you please share print screens with your mapping?


Best way to filter collection queries

Posted: Mon Feb 23, 2015 10:07 pm
by Colten Tenney

Here are the maps of before send and success for the query service
Image
Image


Best way to filter collection queries

Posted: Tue Feb 24, 2015 1:04 am
by Colten Tenney

I can probably get it to work by somehow mapping the $ to the other collapsible blocks and then using ' value.LocationID ' in the javascript to make a conditional test. But not sure if that would work.


Best way to filter collection queries

Posted: Tue Feb 24, 2015 8:16 pm
by Colten Tenney

Any insight on how to do something like this?


Best way to filter collection queries

Posted: Tue Feb 24, 2015 8:17 pm
by Evgene Karachevtsev

Colten,

We are working on it and will get back to you with the update.


Best way to filter collection queries

Posted: Tue Feb 24, 2015 10:47 pm
by Colten Tenney

Thank you very much


Best way to filter collection queries

Posted: Wed Feb 25, 2015 4:34 am
by Yurii Orishchuk

HI Cotten,

How do you populate list of collapsibles(locations)?

If do it in accordance to DB(dynamically) - you can not do it with standard DB service cause of these services returns single entity response list.

To build multilevel lists - you need to have multilevel service response.

You have here two main directions:

  1. Use generic security context. Inside this context you will change response to multilevel.

  2. Use server code to build multilevel response.

    Example of multilevel response that you need:

    precode

    [

    { locationName: "location1",
    deals: [
    {name: "deal1"},
    {name: "deal2"}
    ]
    },

    ........

    ]

    /code/pre

    Regards.


Best way to filter collection queries

Posted: Wed Feb 25, 2015 5:23 am
by Colten Tenney

Thanks
I wish there was more documentation explaining multilevel responses. Is it true that adding an array column to a collection will enable a multilevel response as described here
https://getsatisfaction.com/apperyio/...
However I don't think this array method will work with my setup without a complete overhaul.


Best way to filter collection queries

Posted: Thu Feb 26, 2015 2:36 am
by Yurii Orishchuk

Hi Cotten,

Custom service could return any response. With Appery.io REST services you can not get such response(in your case). Thus you need create this response yourself.

Here is a more detailed response example:

pre

[
{
locationName: "location1",
deals: [
{name: "deal1"},
{name: "deal2"}
]
},

Code: Select all

{ 
    locationName: "location2", 
    deals: [ 
       {name: "deal4"}, 
       {name: "deal6"} 
    ] 
}, 

{ 
    locationName: "location3", 
    deals: [ 
       {name: "deal11"}, 
       {name: "deal25"} 
    ] 
}, 

]

/pre

So here is an array(first level) of objects with other array(second level) inside.

Regards