行式填报表如何复制选中行的数据



在行式填报表中,有插入,添加,删除数据的功能。有些时候客户希望点击“插入”或者“添加”按钮时,能复制选中行的数据。

下面我们一起来看一下如何实现这种效果:

首先设置一张行式填报表,设置其更新属性及单元格的可写属性为“可写”。

 

然后右键单击A3单元格,选择“填报属性”,在其流水号中写:getUuid(),注意:这里并不需要设置流水号。


然后一个发布报表的JSP,在该JSP中增加几个自定义按钮,如下图:

 

其中_insertRow123(report1)和_appendRow123(report1)是我重写了一下report4.jar中已经封装好了的名为_insertRow(report1)和_appendRoe(report1)的js函数,如下图:

(我这里只是重新命名了一下,其余的都没变)

<script language=”javascript”>

function _insertRow123(table){   

       alert(’插入行‘);//这句可要可不要

              if( !_submitEditor( table ) ) return;

       if( table.currCell == null ) {

              alert( __UU );

              return;

       }

       var row = table.currCell.parentElement;

       if( !row.isDetail ) {

              alert( __VV );

              return;

       }

       var index = row.rowIndex;

       while( !row.isFirst ) {

              index–;

              row = table.rows[ index ];

       }

       _copyRows( table, row, index );

       _calcRowNoInGroup( table, row );

}

function _appendRow123(report1){    

       alert(”追加行“);//这句可要可不要

       if( !table.isImport ) {

              if( !_submitEditor( table ) ) return -1;

       }

       var index = -1;

       if( table.appendIndex == null || table.appendIndex < 0 ) {

              if( table.currCell == null ) {

                     alert( __WW );

                     return -1;

              }

              var row = table.currCell.parentElement;

              if( !row.isDetail ) {

                     alert( __XX );

                     return -1;

              }

              index = row.rowIndex;

              while( !row.isFirst ) {

                     index–;

                     row = table.rows[ index ];

              }

              table.baseRow = row;   //要复制的记录的首行

              var srcCell = row.cells[0].sc;

              while( true ) {

                     index++;

                     var r = table.rows[ index ];

                     if( r == null ) {

                            index = -1;

                            break;

                     }

                     if( !r.isDetail ) break;

                     if( r.isFirst && r.cells[0].sc != srcCell ) break;

              }

              if( table.isImport ) table.appendIndex = index;

       }

       else index = table.appendIndex;

       var rowno = _copyRows( table, table.baseRow, index );

       if( table.isImport ) {

              table.appendIndex = rowno + parseInt( table.baseRow.drows );

       }

       _calcRowNoInGroup( table, table.baseRow );

       return rowno;

}

</script>

当点击“插入行”之后,报表会自动复制所选中行的数据,如下图:

 

说明:插入行是选中行的下一行进行复制,追加行是在报表的最后一行复制所选中行的数据。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值