2012-03-12 5 views
0

yuiデータテーブルセルを参照して、インライン日付セルエディタの位置を["tr"、 "br"]に設定します。どうやってやるの?yuiデータテーブルで日付セルエディタのコンテキスト位置を設定するには

この方法が動作しない - column.editor.cfg.setProperty( "文脈"、[ターゲット、 "TR"、 "BR"])

私はデータテーブルのdoBeforeShowCellEditorメソッドをオーバーライドし、変更

答えて

0

が出発点として Dheeraj Kumar Aggarwalのコードを使用して...私はパーティーに遅刻だけど、私は完全に好きな、私は 『d』を定めるなど、いくつかの改良を加え。以下のコードは、セルエディタが水平または垂直(またはその両方)のいずれかで画面の端から外れた場合にのみ、セルエディタを再配置します。

objDataTable.doBeforeShowCellEditor = function(cellEditor){ 
    if(cellEditor.calendar){ 
     // Move Editor 
     var d = YAHOO.util.Dom, 
      elContainer = cellEditor.getContainerEl(), 
      elTd = cellEditor.getTdEl(elContainer), 
      x = d.getX(elTd), 
      y = d.getY(elTd); 
      numWindowWidth = d.getDocumentWidth(); /// The size of the browser frame 
      numWindowHeight = d.getDocumentHeight(); /// The size of the browser frame 
     //TODO: remove scrolling logic 
     // SF doesn't get xy for cells in scrolling table 
     // when tbody display is set to block 
     if(isNaN(x) || isNaN(y)) { 
      // console.log('this.getTbodyEl()',this.getTbodyEl(),'this',this); 
      var elTbody = this.getTbodyEl(); 
      x = elTd.offsetLeft + // cell pos relative to table 
       d.getX(elTbody.parentNode) - // plus table pos relative to document 
       elTbody.scrollLeft; // minus tbody scroll 
      y = elTd.offsetTop + // cell pos relative to table 
       d.getY(elTbody.parentNode) - // plus table pos relative to document 
       elTbody.scrollTop + // minus tbody scroll 
       this.getTheadEl().offsetHeight; // account for fixed THEAD cells 
     } 
     cellEditor.show(); 
     //alert(x + " : X : width : " + elContainer.offsetWidth); 
     if (x + elContainer.offsetWidth > numWindowWidth) { 
      x = x - elContainer.offsetWidth + elTd.offsetWidth; 
     } 
     if (y + elContainer.offsetHeight > numWindowHeight) { 
      y = y - elContainer.offsetHeight + elTd.offsetHeight; 
     } 
     //alert(x + " : X"); 
     elContainer.style.left = x + 'px'; 
     elContainer.style.top = y + 'px'; 
     // console.log('x',x,'y',y,'elContainer',elContainer); 
    } 
    return true; 
}; 
1

セルエディタのコンテキスト位置ロジック。ほとんどのコードは、YUIベースチェッカーのmove関数からコピーされます。 http://developer.yahoo.com/yui/docs/YAHOO.widget.BaseCellEditor.html

DataTable.doBeforeShowCellEditor = function(cellEditor){ 
    if(cellEditor.calendar){ 
     // Move Editor 
     var elContainer = cellEditor.getContainerEl(), 
     elTd = cellEditor.getTdEl(elContainer), 
     x = d.getX(elTd), 
     y = d.getY(elTd); 
     //TODO: remove scrolling logic 
     // SF doesn't get xy for cells in scrolling table 
     // when tbody display is set to block 
     if(isNaN(x) || isNaN(y)) { 
     var elTbody = this.getTbodyEl(); 
     x = elTd.offsetLeft + // cell pos relative to table 
      d.getX(elTbody.parentNode) - // plus table pos relative to document 
      elTbody.scrollLeft; // minus tbody scroll 
     y = elTd.offsetTop + // cell pos relative to table 
      d.getY(elTbody.parentNode) - // plus table pos relative to document 
      elTbody.scrollTop + // minus tbody scroll 
      this.getTheadEl().offsetHeight; // account for fixed THEAD cells 
     } 
     cellEditor.show(); 
     //alert(x + " : X : width : " + elContainer.offsetWidth); 
     x = x - elContainer.offsetWidth + elTd.offsetWidth; 
     //alert(x + " : X"); 
     elContainer.style.left = x + "px"; 
     elContainer.style.top = y + "px";   
    } 
    return true; 
    }; 
関連する問題