4 Replies Latest reply on Sep 13, 2010 12:14 PM by Calculoso

    Datagrid displaying NULL integers as 0




      The data for a given table is displayed in the Flex datagrid as 0 when the integer/double has a NULL value.  Is there a way to properly display NULL without making a label function for every field (with 49 tables and 15/20 fields per table, this would be a tedious exercise)?  The real problem I am faced with is that all NULL values for integers/doubles are overwritten with a 0 value once the given row is edited.  Since the user still sees the same value, they are none-the-wiser.


      In the separate form for editing, I use the DG.selectedItem.[FieldName] to populate each formItem so using labelfunctions would probably not be the best solution.  I am saving the record using the current text in each field (converted if necessary).


      Hopefully that is enough info and thanks in advance!



        • 1. Re: Datagrid displaying NULL integers as 0
          jfb00 Level 3


          Datagrid columns has a label function like = labelFunction="formatNumber"

          formatNumber will be the place that you can do the format as 0 if it's null.


          private function formatNumber(item:Object, dc:DataGridColumn):String
                          if (item==null)){
                              return "0";
                              return item[dc.dataField] //here you can also use formatter for number if you like it.

          i hope this help.




          • 2. Re: Datagrid displaying NULL integers as 0
            Calculoso Level 1



            It is actually the opposite that I want to happen - I want the items to be displayed as NULL when they are, in fact, NULL values.  I do not have a label function for this field and the NULL value is still written as a 0.  This 0 is then used (improperly) as the value for the row when the user saves data, overwriting the NULL value that should be there.


            It may be an issue with WebORB, however, as I cannot seem to save the field as a NULL value either (using a binding like "source = '{Number(someField'sTextBox.text)} destination = '{savedRow.someField}').

            • 3. Re: Datagrid displaying NULL integers as 0
              jfb00 Level 3


                             if (item=="0")){
                                  return "";
                                  return item[dc.dataField]


              At the time you save the data it should be validation to pass null to the database.



              • 4. Re: Datagrid displaying NULL integers as 0
                Calculoso Level 1

                It appears as though WebORB does not process data the same way (i.e. a value "saved" as an empty field "" and a value saved as "NULL" are registered as zeroes upon saving the record).  Thanks for the suggestion, though.  Probably would have worked if WebORB allowed for this (it seems strange that they would not...)