• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Adobe Live Cycle Date Time based table rows sorting

New Here ,
Jan 26, 2025 Jan 26, 2025

Copy link to clipboard

Copied

Helle gurus,

Can you please provide a redirect for the javascript codes required to sort the rows of the table below in descending order according to the date and start time, that is, from old to new?

I wrote the code but it was not successful. First table is binding one. Second one can be used for sorting one or first one. 

DatetimeAscendingTableSorting.jpg

var tableRows = xfa.resolveNodes(“FormServiceRequestConfirmation.bdyMain1.frmTimeEntries.tblTimeEntries1.Row1[*]”);

// Convert rows to an array for sorting
var rowsArray = [];
for (var i = 0; i < tableRows.length; i++) {
rowsArray.push(tableRows.item(i));
}

// Sort array by colDate
rowsArray.sort(function (a, b) {
var dateA = new Date(a.colDate.rawValue); // Parsing colDate as a date
var dateB = new Date(b.colDate.rawValue);

// Compare dates (ascending order)
if (dateA < dateB) return -1;
if (dateA > dateB) return 1;
returns 0;
});

// Reorder the table by sorted rows
for (var j = 0; j < rowsArray.length; j++) {
// Copy sorted row values back to table rows
var sortedRow = rowsArray[j];

FormServiceRequestConfirmation.bdyMain1.frmTimeEntries.tblTimeEntries.Row1[j].colDate.rawValue = sortedRow.colDate.rawValue;
FormServiceRequestConfirmation.bdyMain1.frmTimeEntries.tblTimeEntries.Row1[j].colTimeType.rawValue = sortedRow.colTimeType.rawValue;
FormServiceRequestConfirmation.bdyMain1.frmTimeEntries.tblTimeEntries.Row1[j].colStartTime.rawValue = sortedRow.colStartTime.rawValue;
FormServiceRequestConfirmation.bdyMain1.frmTimeEntries.tblTimeEntries.Row1[j].colEndTime.rawValue = sortedRow.colEndTime.rawValue;
FormServiceRequestConfirmation.bdyMain1.frmTimeEntries.tblTimeEntries.Row1[j].colDuration.rawValue = sortedRow.colDuration.rawValue;
FormServiceRequestConfirmation.bdyMain1.frmTimeEntries.tblTimeEntries.Row1[j].colEmployee.rawValue = sortedRow.colEmployee.rawValue;
FormServiceRequestConfirmation.bdyMain1.frmTimeEntries.tblTimeEntries.Row1[j].colContract.rawValue = sortedRow.colContract.rawValue;
}

 

 

Thanks

John

TOPICS
Scripting

Views

29

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
no replies

Have something to add?

Join the conversation