[CLOSED] GridPanel null values and ModelField.UseNull

  1. #1

    [CLOSED] GridPanel null values and ModelField.UseNull

    In the following image I want to show you 2 differences between v2 and v3.
    #1 v2 shows correcty null values ("pickup date" column is null), but v3 renders it in a bad way even stops drawing then remaining fields to the end of the row.
    It's quite difficult to reprocude a sample project, but I noticed that there is a undocumented breaking change in the UseNull property of ModelField. I tried to replace it with AllowNull, but I don't know if it is right.


    #2 the textbox width of the current page in the gridpanel pager is much smaller than in v2
    Attached Thumbnails Click image for larger version. 

Name:	grid-nulls.png 
Views:	17 
Size:	87.8 KB 
ID:	17771  
    Last edited by Daniil; Dec 31, 2014 at 3:10 PM. Reason: [CLOSED]
  2. #2
    For more information about ModelField's AllowNull: http://forums.ext.net/showthread.php...eaking-Change)
    Last edited by RCN; Dec 29, 2014 at 5:23 AM.
  3. #3
    After replacing UseNull by AllowNull, what results you got?
  4. #4
    I got the result displayed in the image.
    The image already shows the columns with ALlowNull=True.

    I'll try to create a repro-project and post it here.
  5. #5
    I'll try to create a repro-project and post it here
    It would help a lot
  6. #6
    Sorry it was my fault; probably the renderer has been changed from v2 and v3 and reproducing the issue I have been able to found that it is about a javascript which didn't handle null values.

    I post the codebehind to reproduce the issue, you can create a new vb web forms empty project and create a webform called GridTest.
    in code behind paste this

    in my original code was missing in line 99 return s==null?''

    Imports Ext.Net
    
    Public Class GridTest
        Inherits System.Web.UI.Page
    
        Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    
            'Preparing data
            Dim tbl As New DataTable
            tbl.Columns.Add("id", System.Type.GetType("System.Int32"))
            tbl.Columns.Add("txt", System.Type.GetType("System.String"))
            tbl.Columns.Add("dat", System.Type.GetType("System.DateTime"))
            tbl.Columns.Add("time", System.Type.GetType("System.TimeSpan")) 'Removing this column it works
            tbl.Columns.Add("txt2", System.Type.GetType("System.String"))
    
            Dim row As DataRow = tbl.NewRow
            With row
                .Item("id") = 1
                .Item("txt") = "text"
                .Item("dat") = Now
                .Item("txt2") = "text #2"
            End With
    
            tbl.Rows.Add(row)
    
            Dim row2 = tbl.NewRow
            With row2
                .Item("id") = 2
                .Item("txt") = "new text"
                .Item("dat") = DBNull.Value
                .Item("txt2") = "new text #2"
            End With
            tbl.Rows.Add(row2)
    
            'Preparing model
            Dim m As New Model
            For Each c In tbl.Columns
    
                Dim mf As New ModelField
                Dim mft As ModelFieldType
    
                Select Case c.DataType.ToString
                    Case "System.Boolean"
                        mft = ModelFieldType.Boolean
    
                    Case "System.Int32"
                        mft = ModelFieldType.Int
    
                    Case "System.DateTime"
                        mft = ModelFieldType.Date
    
                    Case "Systtem.Decimal"
                        mft = ModelFieldType.Float
    
                    Case Else
                        mft = ModelFieldType.String
    
                End Select
                mf.Name = c.ColumnName
                mf.Type = mft
                mf.NullConvert = True
    
                'UseNull = True 'v2
                mf.AllowNull = True 'v3
    
                mf.SubmitEmptyValue = EmptyValue.Null
                m.Fields.Add(mf)
            Next
    
            'Preparing Store
            Dim s As New Store
            s.ID = "TableStore"
            s.AutoLoad = True
            s.Model.Add(m)
    
            'Preparing the Grid
            Dim grd As New GridPanel
            grd.Height = 200
            grd.Width = 500
    
            Dim rowSelector As New ImageCommandColumn With {.Width = 25, .Resizable = False, .Align = Alignment.Right}
            rowSelector.Commands.Add(New ImageCommand With {.Icon = Ext.Net.Icon.Disk})
    
            'Adding columns
            For Each c As DataColumn In tbl.Columns
                Dim col As ColumnBase
    
                Select Case c.DataType.ToString
                    Case "System.Boolean"
                        col = New CheckColumn With {.Text = c.Caption, .DataIndex = c.ColumnName, .Align = Alignment.Center}
    
                    Case "System.Int32"
                        col = New NumberColumn With {.Text = c.Caption, .DataIndex = c.ColumnName, .Align = Alignment.Right, .Format = "0"}
    
                    Case "System.DateTime"
                        col = New DateColumn With {.Text = c.Caption, .DataIndex = c.ColumnName, .Format = "dd/m/Y"}
    
                    Case "System.TimeSpan"
                        col = New DateColumn With {.Text = c.Caption, .DataIndex = c.ColumnName, .Renderer = New Renderer With {.Fn = "function(s) {return s==null?'':s.substr(0,s.length - 3)}"}}
    
                    Case "System.Decimal"
                        col = New NumberColumn With {.Text = c.Caption, .DataIndex = c.ColumnName, .Align = Alignment.Right, .Format = "0.00"}
    
                    Case Else
                        col = New Column With {.Text = c.Caption, .DataIndex = c.ColumnName}
    
                End Select
    
                grd.ColumnModel.Columns.Add(col)
            Next
    
            grd.Store.Add(s)
            grd.Store(0).DataSource = tbl
    
            'Adding controls
            Dim rm As New ResourceManager
            Me.Controls.Add(rm)
            Me.Controls.Add(grd)
    
        End Sub
    
    End Class
  7. #7
    May this thread be marked as closed?
  8. #8
    Sure! Mark as closed, thank you and happy new year :)
  9. #9
    Let us know if you need further assistance.

    Happy new year bbros :)

Similar Threads

  1. GridPanel sorting null values - bad order
    By gercas in forum 1.x Help
    Replies: 4
    Last Post: Apr 03, 2018, 10:17 AM
  2. [CLOSED] ModelField' UseNull is missing (Breaking Change)
    By RCN in forum 3.x Legacy Premium Help
    Replies: 2
    Last Post: Dec 18, 2014, 2:45 PM
  3. [CLOSED] GridPanel - filtering by null values.
    By altranvfdev3 in forum 2.x Legacy Premium Help
    Replies: 1
    Last Post: Nov 28, 2014, 1:46 PM
  4. [CLOSED] ModelField useNull when populating from HTTP handler
    By cwolcott in forum 2.x Legacy Premium Help
    Replies: 2
    Last Post: May 12, 2014, 4:11 PM
  5. Replies: 1
    Last Post: Nov 07, 2013, 2:40 PM

Posting Permissions