PDA

View Full Version : [CLOSED] GridPanel null values and ModelField.UseNull



bbros
Dec 28, 2014, 10:18 PM
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.
http://forums.ext.net/attachment.php?attachmentid=17771&stc=1

#2 the textbox width of the current page in the gridpanel pager is much smaller than in v2

RCN
Dec 29, 2014, 5:16 AM
For more information about ModelField's AllowNull: http://forums.ext.net/showthread.php?49062-CLOSED-ModelField-UseNull-is-missing-(Breaking-Change)

RCN
Dec 29, 2014, 5:27 AM
After replacing UseNull by AllowNull, what results you got?

bbros
Dec 29, 2014, 7:21 AM
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.

RCN
Dec 29, 2014, 7:37 AM
I'll try to create a repro-project and post it here

It would help a lot

bbros
Dec 29, 2014, 10:15 AM
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

RCN
Dec 29, 2014, 10:26 AM
May this thread be marked as closed?

bbros
Dec 29, 2014, 10:48 AM
Sure! Mark as closed, thank you and happy new year :)

RCN
Dec 29, 2014, 10:55 AM
Let us know if you need further assistance.

Happy new year bbros :)