0

我正在使用 Richfaces 在 Jsf 中工作。我通过添加一个 javascript 文件来自定义 rich:extendedDataTable 以允许调整列的宽度。所以我有一个rich:extendedDataTable 作为头表,我执行以下步骤:

  1. 该表包含许多行数据。
  2. 我双击一行我得到了该行详细信息的另一个表(丰富的:extendedDataTable 也是)
  3. 我在详细信息表中选择一行,然后在按钮中选择一行(键入“h:commandButton”)以将其信息导出为 pdf 文件
  4. 我回到主桌

所以我失去了调整列大小的行为,这是我的问题,我在出现问题之前和之后使用谷歌浏览器进行调试,这是重要差异的结果:

前:

<colgroup id="id_form_reg:EnteteRegGlo:colgroup:header">
<col width="51.35">
<col width="102.7">

<span id="id_form_reg:EnteteRegGlo_hdrop_j_id2318right" class="extdt-hdrop" style="visibility: hidden; top: 0px; left: 0px; height: 0px; width: 0px;">

<div id="id_form_reg:EnteteRegGlo:j_id2318header:menuDiv" class="extdt-menu-div-out" style="top: 0px; left: -1px;">

<colgroup id="id_form_reg:EnteteRegGlo:colgroup:body">
<col width="51.35">
<col width="102.7">

后:

<colgroup id="id_form_reg:EnteteRegGlo:colgroup:header">
<col width="null">
<col width="null">

<span id="id_form_reg:EnteteRegGlo_hdrop_j_id2318right" class="extdt-hdrop" style="visibility: hidden; top: 0px; left: 25px; height: 24px; width: 25px;">

<div id="id_form_reg:EnteteRegGlo:j_id2318header:menuDiv" class="extdt-menu-div-out" style="top: 0px; left: 30px;">                     

<colgroup id="id_form_reg:EnteteRegGlo:colgroup:body">
<col width="NaN">
<col width="NaN">   
4

1 回答 1

0

啊,这是代码:

ExtendedDataTable.DataTable.header.prototype.OnSepMouseMove = function(event) {
  if(this.dragColumnInfo && this.dragColumnInfo.mouseDown) {
       if(!this.dragColumnInfo.dragStarted) {
            this.dragColumnInfo.dragStarted = true;
            this._showSplitter(this.dragColumnInfo.srcElement.columnIndex);
       }
       var delta = Event.pointerX(event) - 
            this.dragColumnInfo.startX
       if (delta < this.minDelta) {
            delta = this.minDelta;
       }
       /*if (delta > this.maxDelta) {
            delta = this.maxDelta;
       }*/
       var x = this.dragColumnInfo.originalX + delta;
       var finalX = x - this.minColumnWidth - 6 //6 stands for sep span width;
       this.columnSplitter.moveToX(finalX);                     
       Event.stop(event);
  }
}

ExtendedDataTable.DataTable.header.prototype.OnSepMouseUp = function(event) {
  Event.stop(event);
  Event.stopObserving(document, 'mousemove', this.eventSepMouseMove);
  Event.stopObserving(document, 'mouseup', this.eventSepMouseUp);
  if(this.dragColumnInfo && this.dragColumnInfo.dragStarted) {
       this.dragColumnInfo.dragStarted = false;
       this.dragColumnInfo.mouseDown = false;

       var delta = Event.pointerX(event) - 
            this.dragColumnInfo.startX;
       if (delta < this.minDelta) {
            delta = this.minDelta;
       }
       /*if (delta > this.maxDelta) {
            delta = this.maxDelta;
       }*/
       var columnIndex = this.dragColumnInfo.srcElement.columnIndex;
       var newWidth = this.getColumnWidth(columnIndex) + delta;

       this.extDt.setColumnWidth(columnIndex, newWidth);
       this.setColumnWidth(columnIndex,newWidth);
       this.extDt.updateLayout();
       if (this.extDt.onColumnResize){
            //set properly value to this.columnWidths
            this.extDt.columnWidths = "";
            for (i=0; i<this.columnsNumber; i++){
                 this.extDt.columnWidths += "" + this.getColumnWidth(i) + ";";
            }//for
            this.extDt.onColumnResize(event, this.extDt.columnWidths);
       }
  }
  this._hideSplitter();
}

ExtendedDataTable.DataTable.prototype.calculateWidthsFromRatios = function() {
LOG.debug('firing calculateWidthsFromRatios');
var c = this.getColumns();
var scrollbarWidth = this.getScrollbarWidth();
this._scrollbarWidth = scrollbarWidth;
LOG.debug('Scrollbar: ' + scrollbarWidth);
var mainDivWidth = this.mainDiv.getWidth();
LOG.debug('Main DIV: ' + mainDivWidth);
var maxWidth = mainDivWidth - scrollbarWidth;
LOG.debug('Width to spread: ' + maxWidth);
var totalWidth = 0;
for (i = 0; i < c.length - 1; i++) {
    LOG.debug('Column[' + i + '] ratio: ' + this.ratios[i]);
    var w = Math.round(this.ratios[i] * maxWidth);
    if (w < parseInt(this.minColumnWidth)) {
        w = parseInt(this.minColumnWidth);
    }
    LOG.debug('setting column ' + i + ' to width: ' + w);
    this.setColumnWidth(i, w);
    this.header.setColumnWidth(i, w);
    totalWidth += w;
}
/*
 * if (totalWidth > maxWidth) {
 * c[c.length - 2].width -= (totalWidth - maxWidth);
 * }
 */
};
于 2014-05-28T16:59:22.160 回答