Custom control - store has rows but all fields are blank

  1. #1

    Custom control - store has rows but all fields are blank

    I've seen some other ppl post something similar, but did not see any solutions. I'm trying to encapsulate a grid in a custom control so the same grid/store can be used in multiple places without recoding.

    When I load the grid, I call FCATGrid.RefreshData(x) from server side code. The store gets 1000+ records, but all fields are blank. If I click refresh on the grid, same thing happens. Any ideas?

    Is there a better way to get this done?

    <ToolboxData("<{0}:FCATGrid runat=server></{0}:FCATGrid>")> _
    Public Class FCATGrid
        Inherits Ext.Net.GridPanel
    
        Private WithEvents PagedStore As New Ext.Net.Store
    
        <Serializable()> _
        Public Class FCATDataObject
            Public Property StudentID As String
            Public Property Name As String
        End Class
    
        Private Sub FCATGrid_Init(sender As Object, e As System.EventArgs) Handles Me.Init
            'include script
            Dim scriptLocation As String = Page.ClientScript.GetWebResourceUrl(Me.GetType(), "VCControls.FCATGrid.js")
            Page.ClientScript.RegisterClientScriptInclude("VCControls.FCATGrid.js", scriptLocation)
        End Sub
    
    #Region "Constructors"
        Public Sub New()
            'bottom bar
            Dim BottomBar As New Ext.Net.PagingToolbar
            With BottomBar
                .ID = "PagingToolbar1"
                .DisplayInfo = True
                .LabelStyle = "font-weight:bold;"
                .DisplayMsg = "Displaying students {0} - {1} of {2}"
                .EmptyMsg = "No students to display"
            End With
    
            Me.BottomBar.Add(BottomBar)
    
            Dim objStore As Ext.Net.Store = PagedStore
            Dim objReader As New Ext.Net.ArrayReader
    
            With objReader
                .IDProperty = "StudentID"
    
                .Fields.Add("StudentID")
                .Fields.Add("Name")
             End With
    
            objStore.Reader.Add(objReader)
            objStore.DirectEventConfig.Timeout = 120000
    
            Store.Add(objStore)
    
            'Demo data: columns 0-9
            Dim fullName As New Ext.Net.Column With {.ColumnID = "fullName", .Header = "Full Name", .DataIndex = "Name", .Width = "150", .Hideable = False}
    
            ColumnModel.Columns.Add(fullName)
        End Sub
    
        Public Sub New(ByVal config As GridPanel.Config)
            MyBase.New(config)
        End Sub
    #End Region
    
        Public Function GetData() As List(Of FCATDataObject)
            Return GetData(0)
        End Function
    
        Public Function GetData(ByVal GroupID As Long) As List(Of FCATDataObject)
    .
    .
    .
            Return objList
        End Function
    
    
        Public Sub RefreshData(ByVal GroupID As Long)
            GetStore().DataSource = GetData(GroupID)
            GetStore().DataBind()
            Me.DataBind()
        End Sub
    End Class
  2. #2

    Fixed

    I guess when you are building the store in code-behind, you have to specify a mapping.

    .Fields.Add(New Ext.Net.RecordField With {.Name = "StudentID", .Mapping = "StudentID"})
  3. #3
    Hi,

    A RecordField's Mapping the same to its Name should not be a solution, it's rather a background effect.

    I guess you should use JsonReader instead of ArrayReader.

    Please note that JsonReader expects an array/list of objects, but ArrayReader expects an array of arrays.

Similar Threads

  1. Allow Blank fields of textbox
    By Vaishali in forum 1.x Help
    Replies: 1
    Last Post: Feb 09, 2012, 9:24 AM
  2. Replies: 1
    Last Post: Dec 19, 2011, 7:00 PM
  3. Fields spaces blank
    By pc.cotemig in forum 1.x Help
    Replies: 1
    Last Post: Jun 03, 2011, 2:57 PM
  4. [CLOSED] [1.0] combobox load blank rows from store
    By PoloTheMonk in forum 1.x Legacy Premium Help
    Replies: 3
    Last Post: Jul 30, 2010, 9:35 AM
  5. Replies: 1
    Last Post: May 15, 2009, 4:51 AM

Tags for this Thread

Posting Permissions