Page 1 of 2

Iterate mapping over a grid, 3 per row ( or more)

Posted: Tue Oct 07, 2014 7:21 pm
by LuisMa Suárez Gutiérrez

i want to iterate over a grid. filling a list.
I did so successfully on one-item-per-row, its too space-consuming and unattractive

how can i iterate 3 at a time?
instead of this:
iterate{ grid(i) ↓ }

i want this
iterate { grid(i, i+1, i+2)↓ }

this is the mock-up of the ui we want. If it were one entry per row it just iterates downward.we've done that, how can i solve this?
http://gyazo.com/637b22e7bac5c73b10d7...


Iterate mapping over a grid, 3 per row ( or more)

Posted: Wed Oct 08, 2014 2:42 am
by Yurii Orishchuk

Hi LuisMa,

Here is a brief plan for it:

1 create table with three items inside.

2 modify your service to combine 3 items inside 1 item.
2.1 First way is to use "generic security context" for service.
2.2 Second way is to use "generic service" which is invokes your service, receive result and then modify it to combine.
2.3 Third way is use server code - to make this modification on server side.

3 Link three items per one grid in the mapping.

Regards.


Iterate mapping over a grid, 3 per row ( or more)

Posted: Wed Oct 08, 2014 8:48 pm
by LuisMa Suárez Gutiérrez

ehem, yeah, i wasn't able to do it. Sorry. i didnt understand
it's a market database. each item is the merchant and what he sales, ( his niche)
its the list_service for a database in appery.

This is the first thing i tried. i just mapped name and niche to all 3 gridCell_labels

http://gyazo.com/45308395b537d57be452...
I got this, it uses the same item for all columns
[joe,peppers] - [joe,peppers] - [joe,peppers]
[anne,Shoes] - [anne,Shoes] - [anne,Shoes]
[tom,phones] - [tom,phones] - [tom,phones]
[Tony,Pets] - [Tony,Pets] - [Tony,Pets]
didn't work

then i did this:
http://gyazo.com/b7978ac13b30af8fd4bb...
i got this, only the first col iterate. the other two stay as in the app builder
[joe,peppers] - [liv,cables] - [peter,dice]
[anne,Shoes] -[liv,cables] - [peter,dice]
[tom,phones] - [liv,cables] - [peter,dice]
[Tony,Pets] - [liv,cables] - [peter,dice]

can this work? http://gyazo.com/bb0b8d6d1d728ace5617... i havent tried it. i make the iteration jump 3 at a time and just add items i,i+1 and i+2


Iterate mapping over a grid, 3 per row ( or more)

Posted: Thu Oct 09, 2014 2:23 am
by Yurii Orishchuk

Hi LuisMa,

Did you combine every 3 items into new array items?

If so you should have data structure like:

pre

  • itemNew1

    • itemOld1
    • itemOld2
    • itemOld3
  • itemNew2

    • itemOld4
    • itemOld5
    • itemOld6

    ...

    /pre

    After you can map all three items into one grid with three cells.

    Regards.


Iterate mapping over a grid, 3 per row ( or more)

Posted: Thu Oct 09, 2014 2:34 am
by LuisMa Suárez Gutiérrez

No. I didn't I don't have any idea how to do that.
I need to modify my source database? o.O
Or do I create a model structure and create a mapping.? I'm really lost.I don't understand how I can "combine" items.


Iterate mapping over a grid, 3 per row ( or more)

Posted: Thu Oct 09, 2014 3:38 am
by Yurii Orishchuk

Ok, lets try to do it with generic security context.

1 Create custom security context service. How to do that is here - http://docs.appery.io/documentation/g...

2 Use next code to wrap answer and make custom logic (remove items which is you do not need).

pre

Appery.MySecurityGeneric = Appery.createClass(SecurityContext, {

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

Code: Select all

     var onSuccess = function(value, other){ 

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

         //here you can change service response. 

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

     settings.success = onSuccess; 

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

});

/pre

Note you should to replace "MySecurityGeneric" with your security generic context name.

3 After you create generic security context please use this context in your service. http://prntscr.com/3e366e/direct

Regards.


Iterate mapping over a grid, 3 per row ( or more)

Posted: Fri Oct 10, 2014 9:11 pm
by LuisMa Suárez Gutiérrez

ok
so i got aroound to try to implement this.

i used this wrapper code:

$t.prueba = Appery.createClass(SecurityContext, {
invoke: function(service, settings) {
var oldSuccess = settings.success;
var onSuccess = function(value, other)
{
var newvalue=[];
var newresponse=[];
for ( var i= 0; ipre

  • itemNew1

    • itemOld1
    • itemOld2
    • itemOld3
  • itemNew2

    • itemOld4
    • itemOld5
    • itemOld6
      ...
      /pre
      i get this http://gyazo.com/a7211e3d42d77843217f...
      a 3 item array. i should get x groups of 3 items right?
      array= [ [i1,i2,i3],[i1,i2,i3],[i1,i2,i3] ]

    what am i missing?
    Im really close to figuring this out.


Iterate mapping over a grid, 3 per row ( or more)

Posted: Mon Oct 13, 2014 3:05 am
by Yurii Orishchuk

Hi LuisMa,

It seems you have syntax error in your code.

Take a look on screen shot: http://prntscr.com/4vntkp/direct

Also please show us full structure of result object. http://prntscr.com/4vnvas/direct

Regards.


Iterate mapping over a grid, 3 per row ( or more)

Posted: Mon Oct 13, 2014 8:16 am
by LuisMa Suárez Gutiérrez

Holy crap! this worked.

pre
var onSuccess = function(value, other){
var newresponse=[];
var newvalue=[];
for (var j=0 ;j/pre
For some reason i don't see the code rendered correctly, I used a pre tag, how do you render multiline code? screenshot: http://gyazo.com/ae99f63ccad5e3b76a75...

results:
first part: http://gyazo.com/9a23c138a2a5b683d930...
second part : http://gyazo.com/e2ae1b7fbdb2baefad68...

ok , so whats next ?

service is still unaffected : ( I see one array of many objects, instead of many arrays of 3 objects ) : http://gyazo.com/48274d93255b1f35de9c...

and mapping is not affected either: http://gyazo.com/f874b280f14a13629490...


Iterate mapping over a grid, 3 per row ( or more)

Posted: Mon Oct 13, 2014 8:28 am
by LuisMa Suárez Gutiérrez

I just realized I need to erase the entire mapping. i can't delete individual paths. i just click on the X symbol but nothing happens. is this a big problem?

http://gyazo.com/6dc6eac88da65cd5c25a...