Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

Sort Table Data

samuel9294_newb
Level 2
Level 2

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

0 Replies
Niall_O_Donovan
Level 10
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

Steve_L_Walker
Level 10
Level 10

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

kvdvijaykumar
Level 4
Level 4

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

edwintiscareno
Level 1
Level 1

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