Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.

Display table

Avatar

Level 2

Hello all,

I am new to LiveCycle designer and have a question for you , I have a search box that looks up users in AD and displays the answer to a table. the issue is when i serach for a common name like Joe  I get about 20 Joe's in my table. I want  to display only the first  5 names (Joe's)  and then i want to create a button when clicked it display the next five and so forth.

3 Replies

Avatar

Level 10

I think what you need is a table to store your data and then browse through it with 2 buttons?!?

Create your table within code like using normal javascript :

index = 0;

var table = ["Joe1", "Joe2", "Joe3", "Joe4", ..., "Joe20"]

for (var i = index; i < table.length; i++){

     if (i < index + 5){

          Table1.Row1.instanceManager.addInstance(1);

          Table1.Row1.Cell1.rawValue = table[i];

     }

}

Avatar

Level 2

Thank you for your help, could you please be more specific on what i should do , and if possiable can you also explain the code?

Avatar

Level 10

Alright as I understood you want to make a search through the form, or w/e, and return the results in a table but only 5 results at a time...

so once your research is done, insert all results in a table... also declare an index to help you browse through this table...

var index = 0;

var table = [""];

everytime you get a result from the search add it to your table

what you probably want to do is for each results store it in my table...

table[0] = "result1"; <-- this is the first item in the table

table[1] = "result2"; <-- this is the second item in the table

you can also make sure to always add your result at the end of the table like this..

table[table.length] = "result";

(table.length) returns the number of items inside your table, so if length is 0, it will add the result in the first item of your table

once all your data is in the table you can browse through it...

Button Event Next 5 Results

if (index + 5 < table.length){//Make sure your index doesnt get out of bounds

     index += 5;//Change your index to the first item you want to show

}

for (var i = index; i < table.length; i++){//for each items in my table, starting at the index shown with the 5 next results

     if (i < index + 5){//make sure I dont get any further than 5 results after my index

         if (Table1.Row1.instanceManager.count < 5){ //Check if your table is showing the results already

               Table1.Row1.instanceManager.addInstance(1);//Add a row if your table is not yet showing the results

          }

          this.resolveNode("Table1.Row1[" + (i - index).toString() + "].Cell1").rawValue = table[i];//Insert value into table to be shown

          //Row1[" + (i - index).toString() + "] is to make sure you are changing the value of the right row, when you add a row to a table

          //The Row1 becomes "Row1[0]", "Row1[1]", "Row1[2]", "Row1[3]", "Row1[4]", "Row1[5]" AS STRING, its not used like a table

          //(i - index).toString() as your i = index, only "i" increments itself... So when you substract the index value from the "i", it returns the index of the               // value to show in the table

     }

}

Button Event Previous 5 Results

if (index - 5 > 0){//Make sure your index doesnt get out of bounds

     index -= 5;//Change your index to the first item you want to show

}

for (var i = index; i < table.length; i++){

     if (i < index + 5){//make sure I dont get any further than 5 results after my index    

          if (Table1.Row1.instanceManager.count < 5){ //Check if your table is showing the results already

               Table1.Row1.instanceManager.addInstance(1);//Add a row if your table is not yet showing the results

          }

          this.resolveNode("Table1.Row1[" + (i - index).toString() + "].Cell1").rawValue = table[i];//Insert value into table to be shown

          //Row1[" + (i - index).toString() + "] is to make sure you are changing the value of the right row, when you add a row to a table

          //The Row1 becomes "Row1[0]", "Row1[1]", "Row1[2]", "Row1[3]", "Row1[4]", "Row1[5]" AS STRING, its not used like a table

          //(i - index).toString() as your i = index, only "i" increments itself... So when you substract the index value from the "i", it returns the index of the               // value to show in the table

     }

}

As far as I know what you're doing, this is what you need..

There might be some error in the script above, but the syntax should look like it

Hope this help!