Revision: 3340
          http://vexi.svn.sourceforge.net/vexi/?rev=3340&view=rev
Author:   clrg
Date:     2009-01-05 07:53:43 +0000 (Mon, 05 Jan 2009)

Log Message:
-----------
Dynamic table fixing (still not 100% but a lot better than before)

Modified Paths:
--------------
    trunk/widgets/org.vexi.widgets/src/org/vexi/lib/widget/table.t

Modified: trunk/widgets/org.vexi.widgets/src/org/vexi/lib/widget/table.t
===================================================================
--- trunk/widgets/org.vexi.widgets/src/org/vexi/lib/widget/table.t      
2009-01-05 06:59:59 UTC (rev 3339)
+++ trunk/widgets/org.vexi.widgets/src/org/vexi/lib/widget/table.t      
2009-01-05 07:53:43 UTC (rev 3340)
@@ -88,7 +88,7 @@
          *  - tempfirst : the first index of any temporary row data 
          *  - tempfinal : the final index of any temporary row data
          */
-        var loadDataFunc = function(data, index, tempindex, tempcount) {
+        var loadDataFunc = function(data, index, tempindex, tempfinal) {
             if (data == null) throw "tried to load null data";
             var b = th_body;
             var n = b.numchildren;
@@ -118,9 +118,9 @@
             var j = 0;
             var l = rows.length;
             // limit display to those visible
+            var start = viewindex>index?viewindex-index:0;
             var count = data.length;
-            count = index+count>viewfinal?viewfinal-index:count;
-            var start = viewindex>index?viewindex-index:0;
+            if (count+index>viewfinal) count = viewfinal-index+1;
             for (var i=start; count>i; i++) {
                 // assign new row
                 var r_ind = index+i;
@@ -163,9 +163,30 @@
         
         var callFetchData = function(fetchfull) {
             // establish the rows the table is attempting to view
-            viewindex = max(floor((-th_bodyview.y) / rowheight), 0);
-            viewfinal = min(numrows, viewindex+ceil(th_bodyport.height / 
rowheight)+1);
+            viewindex = max(floor(viewy / rowheight), 0);
+            viewfinal = min(numrows-1, viewindex+ceil(th_bodyport.height / 
rowheight)-1);
             if (setViewInfo) setViewInfo(viewindex, viewfinal-viewindex+1);
+            // keep body/rows in sync with bodyport
+            var b = th_body;
+            var n = b.numchildren;
+            b.height = height;
+            // our starting y position for offsetting rows
+            viewoffset = -(ceil(viewy)%rowheight);
+            for (var i=0; n>i; i++) {
+                r = b[i];
+                if (r) {
+                    if (fetchfull) {
+                        r.y = -rowheight;
+                        r.rowindex = -1;
+                        continue;
+                    }
+                    var ind = r.rowindex;
+                    if (ind>=viewindex and viewfinal>=ind) {
+                        r.y = viewoffset + (rowheight*(ind-viewindex));
+                    } else r.y = -rowheight;
+                }
+            }
+            // establish fetching parameters
             var fetchindex, fetchcount;
             // fetch all the rows on display
             if (fetchfull or activeindex==null or activeindex>=viewfinal or 
viewindex>=activefinal) {
@@ -190,26 +211,7 @@
             var sortcol = sortby ? th_head.indexof(sortby) : null;
             if (sortcol == -1) sortcol = null;
             var sortorder = sortcol == null ? null : sortasc;
-            var b = th_body;
-            var n = b.numchildren;
-            // keep body in sync with bodyport
-            b.height = height;
-            // our starting y position for offsetting rows
-            viewoffset = -(ceil(viewy)%rowheight);
-            for (var i=0; n>i; i++) {
-                r = b[i];
-                if (r) {
-                    if (fetchfull) {
-                        r.y = -rowheight;
-                        r.rowindex = -1;
-                        continue;
-                    }
-                    var ind = r.rowindex;
-                    if (ind>=viewindex and viewfinal>=ind) {
-                        r.y = viewoffset + (rowheight*(ind-viewindex));
-                    } else r.y = -rowheight;
-                }
-            }
+            // fetch and load returned data
             var data = fetchData(fetchindex, fetchcount, sortcol, sortorder);
             if (data) loadData(data, fetchindex, fetchcount);
         }
@@ -274,6 +276,7 @@
             th_bodyview = fakeviewport[0];
             th_body.align = "topleft";
             th_body.initAsDynamic();
+            th_vscroll.lineshift = rowheight;
             // [un]assign relevant traps
             rowheight ++= static.rowheightWrite;
             selectedindex ++= selectByIndex;
@@ -507,6 +510,7 @@
     static.rowheightWrite = function(v) {
         if (!v) throw "rowtemplate..rowheight must be a valid integer (>0)";
         cascade = v;
+        trapee.th_vscroll.lineshift = rowheight;
         if (trapee.fetchData) trapee.forceFetchData();
     }
     


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

------------------------------------------------------------------------------
_______________________________________________
Vexi-svn mailing list
Vexi-svn@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/vexi-svn

Reply via email to