Updated Rico 2 and Rico 3 with all patches submitted on Sourceforge.
[infodrom/rico3] / minsrc / ricoLiveGrid.js
index 6c89dc1..d550aaf 100644 (file)
@@ -274,7 +274,7 @@ Rico.Buffer.Base.prototype = {
 
   getWindowStyle: function(windowRow,col) {
     var bufrow=this.bufferRow(windowRow);
-    return this.attr && this.isVisible(bufrow) && col < this.attr[bufrow].length ? this.attr[bufrow][col] : '';
+    return this.attr && this.isVisible(bufrow) && this.attr[bufrow] && col < this.attr[bufrow].length ? this.attr[bufrow][col] : '';
   },
 
   getWindowValue: function(windowRow,col) {
@@ -535,8 +535,8 @@ Rico.LiveGrid.prototype = {
 
     this.bookmark=document.getElementById(this.tableId+"_bookmark");
     this.sizeDivs();
-    var filterUIrow=this.buffer.options.canFilter ? this.options.FilterLocation : false;
-    if (typeof(filterUIrow)=='number' && filterUIrow<0)
+    var filterUIrow=-1;
+    if (this.buffer.options.canFilter && this.options.AutoFilter)
       filterUIrow=this.addHeadingRow('ricoLG_FilterRow');
     this.createDataCells(this.options.visibleRows);
     if (this.pageSize == 0) return;
@@ -561,7 +561,7 @@ Rico.LiveGrid.prototype = {
       this.scrollToRow(this.options.offset);
       this.buffer.fetch(this.options.offset);
     }
-    if (typeof(filterUIrow)=='number')
+    if (filterUIrow >= 0)
       this.createFilters(filterUIrow);
     this.scrollEventFunc=Rico.eventHandle(this,'handleScroll');
     this.wheelEventFunc=Rico.eventHandle(this,'handleWheel');
@@ -574,6 +574,13 @@ Rico.LiveGrid.prototype = {
     if (this.options.windowResize)
       Rico.runLater(100,this,'pluginWindowResize');
     Rico.log("initialize complete for "+this.tableId);
+    //alert('clientLeft='+this.scrollDiv.clientLeft);
+    if (this.direction=='rtl' && (!Rico.isWebKit || this.scrollDiv.clientLeft > 0)) {
+      this.scrollTab.style.right='0px';
+    } else {
+      this.scrollTab.style.left='0px';
+      Rico.setStyle(this.tabs[1], {'float': 'left'});
+    }
   }
 };
 
@@ -643,7 +650,7 @@ Rico.LiveGridMethods = {
       var theads=table.getElementsByTagName("thead");
       if (theads.length == 1) {
         Rico.log("createTables: using thead section, id="+this.tableId);
-        if (this.options.PanelNamesOnTabHdr && this.options.panels) {
+        if (this.options.ColGroupsOnTabHdr && this.options.ColGroups) {
           var r=theads[0].insertRow(0);
           this.insertPanelNames(r, 0, this.options.frozenColumns, 'ricoFrozen');
           this.insertPanelNames(r, this.options.frozenColumns, this.options.columnSpecs.length);
@@ -733,7 +740,7 @@ Rico.LiveGridMethods = {
     } else {
       this.createHdr(0,0,this.options.frozenColumns);
       this.createHdr(1,this.options.frozenColumns,this.options.columnSpecs.length);
-      if (this.options.PanelNamesOnTabHdr && this.options.panels) {
+      if (this.options.ColGroupsOnTabHdr && this.options.ColGroups) {
         this.insertPanelNames(this.thead[0].insertRow(0), 0, this.options.frozenColumns);
         this.insertPanelNames(this.thead[1].insertRow(0), this.options.frozenColumns, this.options.columnSpecs.length);
       }
@@ -935,15 +942,15 @@ Rico.LiveGridMethods = {
     r.className='ricoLG_hdg';
     var lastIdx=-1, span, newCell=null, spanIdx=0;
     for( var c=start; c < limit; c++ ) {
-      if (lastIdx == this.options.columnSpecs[c].panelIdx) {
+      if (lastIdx == this.options.columnSpecs[c].ColGroupIdx) {
         span++;
       } else {
         if (newCell) newCell.colSpan=span;
         newCell = r.insertCell(-1);
         if (cellClass) newCell.className=cellClass;
         span=1;
-        lastIdx=this.options.columnSpecs[c].panelIdx;
-        newCell.innerHTML=this.options.panels[lastIdx];
+        lastIdx=this.options.columnSpecs[c].ColGroupIdx;
+        newCell.innerHTML=this.options.ColGroups[lastIdx];
       }
     }
     if (newCell) newCell.colSpan=span;
@@ -1209,11 +1216,13 @@ Rico.LiveGridMethods = {
       newdiv.className = 'ricoLG_cell '+cls;
       newdiv.id=this.tableId+'_'+this.pageSize+'_'+c;
       this.columns[c].dataColDiv.appendChild(newdiv);
-      if (this.columns[c].format.canDrag && Rico.registerDraggable)
-        Rico.registerDraggable( new Rico.LiveGridDraggable(this, this.pageSize, c), this.options.dndMgrIdx );
-      newdiv.innerHTML='&nbsp;';   // this seems to be required by IE
       if (this.columns[c]._create) {
         this.columns[c]._create(newdiv,this.pageSize);
+      } else {
+        newdiv.innerHTML='&nbsp;';   // this seems to be required by IE
+      }
+      if (this.columns[c].format.canDrag && Rico.registerDraggable) {
+        Rico.registerDraggable( new Rico.LiveGridDraggable(this, this.pageSize, c), this.options.dndMgrIdx );
       }
     }
     this.pageSize++;
@@ -1660,13 +1669,6 @@ Rico.LiveGridMethods = {
     return -1;
   },
 
-  findColumnName: function(name) {
-    for (var n=0; n<this.columns.length; n++) {
-      if (this.columns[n].fieldName == name) return n;
-    }
-    return -1;
-  },
-  
 /**
  * Searches options.columnSpecs colAttr for matching colValue
  * @return array of matching column indexes
@@ -1682,8 +1684,8 @@ Rico.LiveGridMethods = {
 /**
  * Set initial sort
  */
-  setSortUI: function( columnNameOrNum, sortDirection ) {
-    Rico.log("setSortUI: "+columnNameOrNum+' '+sortDirection);
+  setSortUI: function( columnIdOrNum, sortDirection ) {
+    Rico.log("setSortUI: "+columnIdOrNum+' '+sortDirection);
     var colnum=this.findSortedColumn();
     if (colnum >= 0) {
       sortDirection=this.columns[colnum].getSortDirection();
@@ -1694,12 +1696,12 @@ Rico.LiveGridMethods = {
         sortDirection=sortDirection.toUpperCase();
         if (sortDirection != Rico.ColumnConst.SORT_DESC) sortDirection=Rico.ColumnConst.SORT_ASC;
       }
-      switch (typeof columnNameOrNum) {
+      switch (typeof columnIdOrNum) {
         case 'string':
-          colnum=this.findColumnName(columnNameOrNum);
+          colnum=this.findColumnsBySpec('id',columnIdOrNum);
           break;
         case 'number':
-          colnum=columnNameOrNum;
+          colnum=columnIdOrNum;
           break;
       }
     }