Datagrid returns a null value, can I replace this?

639 views Asked by At

Hi I have an Advanced Datagrid in flex and on occasions the query that populates this graph will return an empty cell value. when this happens the Datagrid displays "NaN". is there anyway that if my query doesn't return anything the Datagrid cell just remains blank.

thanks mxml: '

                    <mx:AdvancedDataGridColumn headerText="{Mlc.curr.get('address')}" dataField="datafield2" width="{Math.max(180,getStyle('fontSize')))}" />
                    <mx:AdvancedDataGridColumn headerText="{Mlc.curr.get('Name')}" dataField="datafield1" width="{Math.max(180,getStyle('fontSize')))}" />


                </components:columns>
                </components:RowColorDataGrid>

'

as:

accountViewGridCanv.numRows = 1000;
 dgGridCanv.addParameter(Constants.parameter,""); 
 dgGridCanv.itemID = displayItems.indexOf(dgGrid);

basically a query runs to a spreadsheet and results are displayed in a datagrid, but if the cell in the spreadsheet is null then the datagrid displays "NaN"

Thanks Again

1

There are 1 answers

3
Akash Bhardwaj On

This happens when the webservice returns null for a Number datatype. Flex converts it into NaN(Not a Number). Use labelfunction to check if the value in the column is NaN or not. If it is, then return appropriate value to display.eg-

<mx:AdvancedDataGridColumn headerText="Quantity" labelFunction="getTotalQty"/>

now check for NaN in the getTotalQty function

private function getTotalQty(inData:Object, inCol:AdvancedDataGridColumn):Number
    {
        return (isNaN(inData.qty)?0:inData.qty);
    }