Updated Rico2 and Rico3 with fixes for IE9. Updated Rico2 version to 2.3. Updated...
[infodrom/rico3] / ricoClient / js / ricoLiveGrid.js
index 0c69e68..15a08ad 100644 (file)
@@ -478,7 +478,7 @@ Rico.LiveGrid.prototype = {
     Rico.setDebugArea(tableId+"_debugmsgs");    // if used, this should be a textarea
 
     Rico.extend(this.options, {
-      visibleRows      : -1,    // -1 or 'window'=size grid to client window; -2 or 'data'=size grid to min(window,data); -3 or 'body'=size so body does not have a scrollbar; -4 or 'parent'=size to parent element (e.g. if grid is inside a div)
+      visibleRows      : -3,    // -1 or 'window'=size grid to client window; -2 or 'data'=size grid to min(window,data); -3 or 'body'=size so body does not have a scrollbar; -4 or 'parent'=size to parent element (e.g. if grid is inside a div)
       frozenColumns    : 0,
       offset           : 0,     // first row to be displayed
       prefetchBuffer   : true,  // load table on page load?
@@ -495,7 +495,7 @@ Rico.LiveGrid.prototype = {
       highlightClass   : Rico.theme.gridHighlightClass || 'ricoLG_selection',
 
       // export/print parameters
-      maxPrint         : 1000,  // max # of rows that can be printed/exported, 0=disable print/export feature
+      maxPrint         : 5000,  // max # of rows that can be printed/exported, 0=disable print/export feature
 
       // heading parameters
       headingSort      : 'link', // link: make headings a link that will sort column, hover: make headings a hoverset, none: events on headings are disabled
@@ -536,8 +536,8 @@ Rico.LiveGrid.prototype = {
         }
         break;
       default:
-        this.sizeTo='window';
-        this.options.visibleRows=-1;
+        this.sizeTo='body';
+        this.options.visibleRows=-3;
         break;
     }
     this.highlightEnabled=this.options.highlightSection>0;
@@ -685,7 +685,9 @@ Rico.LiveGridMethods = {
     }
 
     this.createDivs();
-    this.scrollTabs = this.createDiv("scrollTabs",this.innerDiv);
+    this.scrollContainer = this.createDiv("scrollContainer",this.structTabLR);
+    this.scrollContainer.appendChild(this.scrollDiv); // move scrollDiv
+    this.scrollTab = this.createDiv("scrollTab",this.scrollContainer);
     this.shadowDiv  = this.createDiv("shadow",this.scrollDiv);
     this.shadowDiv.style.direction='ltr';  // avoid FF bug
     this.scrollDiv.style.display="none";
@@ -701,14 +703,14 @@ Rico.LiveGridMethods = {
         case 'menuCell':
         case 'cursorCell':
           for (i=0; i<2; i++) {
-            this.highlightDiv[i] = this.createDiv("highlight",i==0 ? this.frozenTabs : this.scrollTabs);
+            this.highlightDiv[i] = this.createDiv("highlight",i==0 ? this.frozenTabs : this.scrollTab);
             this.highlightDiv[i].style.display="none";
             this.highlightDiv[i].id+=i;
           }
           break;
         case 'selection':
           // create one div for each side of the rectangle
-          var parentDiv=this.options.highlightSection==1 ? this.frozenTabs : this.scrollTabs;
+          var parentDiv=this.options.highlightSection==1 ? this.frozenTabs : this.scrollTab;
           for (i=0; i<4; i++) {
             this.highlightDiv[i] = this.createDiv("highlight",parentDiv);
             this.highlightDiv[i].style.display="none";
@@ -721,23 +723,31 @@ Rico.LiveGridMethods = {
     }
 
     // create new tables
-    for (i=0; i<2; i++) {
+    for (i=0; i<3; i++) {
       this.tabs[i] = document.createElement("table");
       this.tabs[i].className = 'ricoLG_table';
       this.tabs[i].border=0;
       this.tabs[i].cellPadding=0;
       this.tabs[i].cellSpacing=0;
       this.tabs[i].id = this.tableId+"_tab"+i;
+    }
+    // set headings
+    for (i=0; i<2; i++) {
       this.thead[i]=this.tabs[i].createTHead();
-      this.thead[i].className='ricoLG_top';
+      Rico.addClass(this.tabs[i],'ricoLG_top');
+      //this.thead[i].className='ricoLG_top';
       if (Rico.theme.gridheader) Rico.addClass(this.thead[i],Rico.theme.gridheader);
-      this.tbody[i]=Rico.getTBody(this.tabs[i]);
+    }
+    // set bodies
+    for (i=0; i<2; i++) {
+      this.tbody[i]=Rico.getTBody(this.tabs[i==0?0:2]);
       this.tbody[i].className='ricoLG_bottom';
       if (Rico.theme.gridcontent) Rico.addClass(this.tbody[i],Rico.theme.gridcontent);
       this.tbody[i].insertRow(-1);
     }
     this.frozenTabs.appendChild(this.tabs[0]);
-    this.scrollTabs.appendChild(this.tabs[1]);
+    this.innerDiv.appendChild(this.tabs[1]);
+    this.scrollTab.appendChild(this.tabs[2]);
     if (insertloc) insertloc.parentNode.insertBefore(this.outerDiv,insertloc);
     if (hdrSrc) {
       this.headerColCnt = this.getColumnInfo(hdrSrc);
@@ -1015,11 +1025,19 @@ Rico.LiveGridMethods = {
     var totRowHt=this.columns[firstVisible].dataColDiv.offsetHeight;
     this.rowHeight = Math.round(totRowHt/this.pageSize);
     var scrHt=this.dataHt;
-    if (this.scrWi>0 || Rico.isIE || Rico.isWebKit)
+    if (this.scrTabWi0 == this.scrTabWi) {
+      // no scrolling columns - horizontal scroll bar not needed
+      this.innerDiv.style.height=(this.hdrHt+1)+'px';
+      this.scrollDiv.style.overflowX='hidden';
+    } else {
+      this.scrollDiv.style.overflowX='scroll';
       scrHt+=this.options.scrollBarWidth;
+    }
     this.scrollDiv.style.height=scrHt+'px';
-    this.innerDiv.style.width=(this.scrWi-this.options.scrollBarWidth+1)+'px';
-    this.resizeDiv.style.height=this.frozenTabs.style.height=this.innerDiv.style.height=(this.hdrHt+this.dataHt+1)+'px';
+    this.innerDiv.style.width=(this.scrWi)+'px';
+    this.scrollTab.style.width=(this.scrWi-this.options.scrollBarWidth)+'px';
+    //this.resizeDiv.style.height=this.frozenTabs.style.height=this.innerDiv.style.height=(this.hdrHt+this.dataHt+1)+'px';
+    this.resizeDiv.style.height=(this.hdrHt+this.dataHt+1)+'px';
     Rico.log('sizeDivs scrHt='+scrHt+' innerHt='+this.innerDiv.style.height+' rowHt='+this.rowHeight+' pageSize='+this.pageSize);
     var pad=(this.scrWi-this.scrTabWi < this.options.scrollBarWidth) ? 2 : 0;
     this.shadowDiv.style.width=(this.scrTabWi+pad)+'px';
@@ -1028,8 +1046,9 @@ Rico.LiveGridMethods = {
   },
 
   setHorizontalScroll: function() {
-    var scrleft=this.scrollDiv.scrollLeft;
-    this.scrollTabs.style.left=(-scrleft)+'px';
+    var newLeft=(-this.scrollDiv.scrollLeft)+'px';
+    this.tabs[1].style.marginLeft=newLeft;
+    this.tabs[2].style.marginLeft=newLeft;
   },
 
   remainingHt: function() {
@@ -1040,7 +1059,6 @@ Rico.LiveGridMethods = {
     if (!Rico.isIE && window.frameElement && window.frameElement.scrolling=='yes' && this.sizeTo!='parent') margin+=this.options.scrollBarWidth;
     switch (this.sizeTo) {
       case 'window':
-      case 'data':
         var divTop=Rico.cumulativeOffset(this.outerDiv).top;
         tabHt=Math.max(this.tabs[0].offsetHeight,this.tabs[1].offsetHeight);
         Rico.log("remainingHt, winHt="+winHt+' tabHt='+tabHt+' gridY='+divTop);
@@ -1053,12 +1071,10 @@ Rico.LiveGridMethods = {
         if (Rico.isIE) Rico.show(this.outerDiv);
         Rico.log("remainingHt, parentHt="+parentHt+' gridY='+offset+' winHt='+winHt+' tabHt='+tabHt);
         return parentHt - tabHt - offset - this.options.scrollBarWidth;
+      case 'data':
       case 'body':
-        //Rico.log("remainingHt, document.height="+document.height);
-        //Rico.log("remainingHt, body.offsetHeight="+document.body.offsetHeight);
-        //Rico.log("remainingHt, body.scrollHeight="+document.body.scrollHeight);
-        //Rico.log("remainingHt, documentElement.scrollHeight="+document.documentElement.scrollHeight);
         var bodyHt=Rico.isIE ? document.body.scrollHeight : document.body.offsetHeight;
+        //alert("remainingHt\n document.height="+document.height+"\n body.offsetHeight="+document.body.offsetHeight+"\n body.scrollHeight="+document.body.scrollHeight+"\n documentElement.scrollHeight="+document.documentElement.scrollHeight);
         var remHt=winHt-bodyHt-margin;
         if (!Rico.isWebKit) remHt-=this.options.scrollBarWidth;
         Rico.log("remainingHt, winHt="+winHt+' pageHt='+bodyHt+' remHt='+remHt);
@@ -2386,6 +2402,10 @@ _export: function(v) {
   return this._format(v);
 },
 
+exportBuffer: function(bufRow) {
+  return this._export(this.buffer.getValue(bufRow,this.index));
+},
+
 displayValue: function(windowRow) {
   var bufval=this.getValue(windowRow);
   if (bufval==null) {