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.

Sort Table Data

Avatar

Level 2

is there any way to sort tabel data in livecycle like in excel or word tables?

4 Replies

Avatar

Level 10

Hi,

John Brinkman has a sample here where he sorts a group of subforms. http://blogs.adobe.com/formfeed/2009/05/sort_subforms.html

It should be possible to adapt this to sort rows, but I haven't tried it.

Good luck,

Niall

Avatar

Former Community Member

I put the attached together to demonstrate sorting a static table. If you have a dynamic table then changes will be required. The table header row contains three buttons. When you click Club, Home or Founded all three columns are sorted. I just reverse sort on each click.

Untitled.png

I attached the same script to the click event of all three buttons. Optimize as you see fit. The click event on the Club button is as follows:

// form1.page1.table.header.clubBtn::click - (JavaScript, client)


var clubArray = new Array();

var homeArray = new Array();

var foundedArray = new Array();


for (var i=0; i < 4; i++) {

  var club = xfa.resolveNode("form1.page1.table.row[" + i + "].club").rawValue;

  clubArray.push(club);

  var home = xfa.resolveNode("form1.page1.table.row[" + i + "].home").rawValue;

  homeArray.push(home);

  var founded = xfa.resolveNode("form1.page1.table.row[" + i + "].founded").rawValue;

  foundedArray.push(founded);

}


clubArray.reverse();

homeArray.reverse();

foundedArray.reverse();


for (var i=0; i < 4; i++) {

  xfa.resolveNode("form1.page1.table.row[" + i + "].club").rawValue = clubArray[i];

  xfa.resolveNode("form1.page1.table.row[" + i + "].home").rawValue = homeArray[i];

  xfa.resolveNode("form1.page1.table.row[" + i + "].founded").rawValue = foundedArray[i];

}

Steve

Avatar

Former Community Member

Hi,

I don't think this will work. The reasons are:

1)  Here all the sample data considered is in ascending order

2) Since the data is already organized in asc order, the reverse function works well in all the cases.

This doesn't seem to be a full pledged sorting.

Thanks,

VJ

Avatar

Level 1

Hi, Document attached doesnt work, could you share it to me please? uaembo@gmail.com