How to display empty number field in the gridpanel

  1. #1

    How to display empty number field in the gridpanel

    Hi friends,
    I am new to ext.net. i am exploring ext.net examples. I have one problem.
    In my DataBase i have a table, in wchich a column has all integers and some NULL values. I get the data from this table and bind it to the gridpanel using store.

    But in my gridpanel it is showing '0' instead of empty value. Please help me where i am doing wrong.

    <ext:Store ID="testStore" runat="server" PruneModifiedRecords="true">
            <Reader>
                <ext:JsonReader>
                    <Fields>
                        <ext:RecordField Name="VacationHours" Type="Int">
                        </ext:RecordField>
                        /*other fields here*/
                    </Fields>
                </ext:JsonReader>
            </Reader>
        </ext:Store>
     <ext:GridPanel ID="GridPanel2" runat="server" StoreID="testStore" Height="600" Width="900"
                                    Title="Test Grid">
                                    <ColumnModel>
                                        <Columns>
                                            <ext:Column DataIndex="VacationHours" Header="VacationHours" Width="100">
                                            <Editor>
                                            <ext:NumberField ID="NumberField1" runat="server"
                                             EmptyText="testing Text" SelectOnFocus="true" MaxLength="4">
                                             
                                             </ext:NumberField>
                                                
                                            </Editor>
                                            </ext:Column>
                                           /*other columns*/
                                            <ext:CommandColumn Width="110">
                                                <Commands>
                                                
                                                    <ext:GridCommand Icon="Delete" CommandName="CommandName" Text="Delete" Disabled="false" />
                                                    
                                                    <ext:GridCommand Icon="NoteEdit" CommandName="Edit" Text="Edit" />
                                                    
                                                </Commands>
                                            </ext:CommandColumn>
                                            
                                        </Columns>
                                    </ColumnModel>
                                    <SelectionModel>
                                    <ext:RowSelectionModel runat="server" ID="rowSelectionModel"></ext:RowSelectionModel>
                                    </SelectionModel>
                                    <Listeners> 
                                        <Command Handler="Ext.Msg.alert(command,record.data.Gender)" />
                                        
                                    </Listeners>
                                   
                                </ext:GridPanel>
    Please see the below images i attached to know the original datatable and how it is appearing in the gridpanel.
    Click image for larger version. 

Name:	griddata.PNG 
Views:	99 
Size:	31.3 KB 
ID:	2949Click image for larger version. 

Name:	GridPanel.PNG 
Views:	104 
Size:	20.9 KB 
ID:	2950
  2. #2

    try using a renderer

    Try using a renderer:

    <ext:Column DataIndex="VacationHours" Header="VacationHours" Width="100">
         <Renderer Fn="formatVacaHours" />
    </ext:Column>
    Function would be something like:
        var formatVacaHours= function (value, metadata, record, rowIndex, colIndex, store) {
            //test value
            if (value == null) { return ' ';}
              else return value;
        };
    Something like that.

    -Amit
  3. #3
    Hi Amit,
    Thanks for your reply... i tried your solution but its not working.. when i debug that function it never checking the null values...in the place of null values it it showing '0' . so it always entering into else part..

    so any other solution?

    Thank you...
  4. #4
    Try changing the column to a string.

Similar Threads

  1. Replies: 4
    Last Post: Dec 14, 2012, 10:49 AM
  2. Replies: 1
    Last Post: Mar 29, 2012, 10:42 PM
  3. [CLOSED] Number Field
    By majestic in forum 1.x Premium Help
    Replies: 3
    Last Post: Jan 05, 2011, 12:21 PM
  4. How to display an "Empty Text" label in GridPanel?
    By dbassett74 in forum 1.x Help
    Replies: 7
    Last Post: Feb 17, 2010, 1:19 PM
  5. Number Field
    By fabiomarcos in forum 1.x Help
    Replies: 2
    Last Post: Jan 20, 2009, 11:29 AM

Tags for this Thread

Posting Permissions