dabo Commit
Revision 7253
Date: 2012-09-22 14:00:45 -0700 (Sat, 22 Sep 2012)
Author: Ed
Trac: http://trac.dabodev.com/changeset/7253

Changed:
U   trunk/dabo/ui/uiwx/dGrid.py

Log:
Fixed two issues with renderers.

First, a recent change ended up ignoring any defined custom renderers; that 
should be fixed now. Second, the default behavior for the wx renderer for 
numbers was to show None values as zero; this has now been changed to render 
None value as strings so that they appear correctly.

Diff:
Modified: trunk/dabo/ui/uiwx/dGrid.py
===================================================================
--- trunk/dabo/ui/uiwx/dGrid.py 2012-09-22 17:06:34 UTC (rev 7252)
+++ trunk/dabo/ui/uiwx/dGrid.py 2012-09-22 21:00:45 UTC (rev 7253)
@@ -37,6 +37,7 @@
 decimalPoint = None
 
 
+
 class dGridDataTable(wx.grid.PyGridTableBase):
 
        def __init__(self, parent):
@@ -577,8 +578,12 @@
 
        def _setRenderer(self):
                self._setDataTypeFromDataField()
-               typ = self.getDataTypeForColumn()
-               self._rendererClass = self.defaultRenderers.get(typ, 
self.stringRendererClass)
+               custom = self.CustomRendererClass
+               if custom:
+                       self._rendererClass = custom
+               else:
+                       typ = self.getDataTypeForColumn()
+                       self._rendererClass = self.defaultRenderers.get(typ, 
self.stringRendererClass)
 
 
        @dabo.ui.deadCheck
@@ -688,12 +693,20 @@
 
        def getEditorClassForRow(self, row):
                """Return the cell editor class for the passed row."""
-               d = self.CustomEditors
-               return d.get(row, self.EditorClass)
+               return self.CustomEditors.get(row, self.EditorClass)
 
 
+       def _getValueForRow(self, row):
+               if self.Parent:
+                       return self.Parent.getColumnValueByRow(self, row)
+
+
        def getRendererClassForRow(self, row):
                """Return the cell renderer class for the passed row."""
+               if self._getValueForRow(row) == self.Parent.NoneDisplay:
+                       # Null values in the data should be rendered as strings,
+                       # no matter what type the column is.
+                       return self.stringRendererClass
                return self._customRenderers.get(row, self._rendererClass)
 
 
@@ -2501,6 +2514,7 @@
                if [col for col in self.Columns if col.Expand]:
                        dabo.ui.callAfterInterval(10, 
self._delayedUpdateColumnWidths)
 
+
        def _delayedUpdateColumnWidths(self, redo=False):
                def _setFlag():
                        self._inColWidthUpdate = True
@@ -2804,6 +2818,15 @@
                self.fillGrid(True)
 
 
+       def getColumnValueByRow(self, col, row):
+               """Returns the value in the given column and row."""
+               if isinstance(col, dColumn):
+                       colnum = self.Columns.index(col)
+               else:
+                       colnum = col
+               return self.GetValue(row, colnum)
+
+
        def sizeToColumns(self, scrollBarFudge=True):
                """
                Set the width of the grid equal to the sum of the widths        
of the columns.



_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-dev
Searchable Archives: http://leafe.com/archives/search/dabo-dev
This message: 
http://leafe.com/archives/byMID/[email protected]

Reply via email to