Adobe form template sort

简介: Sent:Monday, March 29, 2010 2:24 PM

I have written a sample about sorting materials by column "SourceLogisticsAreaID", you can easily change the script highlight below to sort by some other fields.


image.pngthere are 7 material nodes in the sample XML data and they have source Logistics Area ID as order : 3,2,1,6,5,7,4. The sorted result looks like in the PDF:


image.pngSome explanation on the scripts:

I fetch all the Materials data nodes and store them in variable root.


var root = $record.SiteLogisticsTask.resolveNodes("SiteLogisticsTask.Activity[].LogisticPackage[].Material[*]");


Since XFA doesn't provide the built swap function based on NodeList ( root has data type NodeList ), I have to writen a swap function by myself. By inserting & removing nodes in xfa.record.SiteLogisticsTask.Activity.LogisticPackage.nodes, I implement the swap function.


The insert & remove operations varies depending on different values of left and right index, that is the reason why you can see 4 if-else in the script.


feel free to change this code if you find there is something to improve.


image.pngimage.pngIf you wouldn't like to write lots of code for swap function, you can use this solution instead, it is far more simple and understandable than the first solution:


we put all Material data nodes into variable "root", and then put it into nodeSet, which is an variable with standard type "Array" in Javascript, so we can use its built in function "sort". Here we need to input a compare function name as a IMPORTING parameter to sort, this compare function tells the standard Javascript function sort about what sorting criterion it must use,


in our example the sorting criterion is "sort by SourceLogisticsAreaID", as we have written in the myCompare implementation.


image.png

相关文章
|
容器
layui框架实战案例(23):在layui-tab-content中layui-progress-bar在html拼接中不显示lay-percent的解决方案
layui框架实战案例(23):在layui-tab-content中layui-progress-bar在html拼接中不显示lay-percent的解决方案
338 0
|
3月前
|
XML 安全 JavaScript
goctl 技术系列 - text/template 深入讲解
goctl 技术系列 - text/template 深入讲解
|
4月前
|
前端开发
前端使用 <el-descriptions>标签报错: <el-descriptions> - did you register the component correctly
前端使用 <el-descriptions>标签报错: <el-descriptions> - did you register the component correctly
263 0
|
6月前
使用Form报错提示If ngModel is used within a form tag, either the name attribute must be set or the form
使用Form报错提示If ngModel is used within a form tag, either the name attribute must be set or the form
【element-ui用法】el-radio-group默认选择和数据回显问题的解决方案
【element-ui用法】el-radio-group默认选择和数据回显问题的解决方案
677 0
element-ui的el-table与el-form的使用与表单校验
element-ui的el-table与el-form的使用与表单校验
element-ui的el-table与el-form的使用与表单校验
elementUI:Upload组件list-type: picture-card上传闪动
elementUI:Upload组件list-type: picture-card上传闪动
563 0
SAP Spartacus User form通过label标签的实现原理
SAP Spartacus User form通过label标签的实现原理
118 0
SAP Spartacus User form通过label标签的实现原理
|
XML 数据格式
SAP Form print tool
Sent: Thursday, October 30, 2008 8:05 PM
SAP Form print tool
SAP UI5 click list item to navigate to detail page
Created by Wang, Jerry, last modified on Mar 23, 2015
103 0
SAP UI5 click list item to navigate to detail page