GridPanel, JSON store and Complex object properties

  1. #1

    GridPanel, JSON store and Complex object properties

    I'm persisting my app's object list to a Store which supplies a GridPanel as per below:

    
    
    
        <ext:Store runat="server" ID="PersonStore">
            <Reader>
                <ext:JsonReader>
                    <Fields>
                        <ext:RecordField Name="Status" IsComplex="true"/>
                        <ext:RecordField Name="StatusName" Mapping="Status.StatusName"/>
                        <ext:RecordField Name="PersonEcdStatus" IsComplex="true"/>
                        <ext:RecordField Name="EcdStatusName" Mapping="PersonEcdStatus.PersonECDStatusName" />
                        <ext:RecordField Name="FullName" Mapping="Surname + ', ' + obj.FirstName"/>
                        <ext:RecordField Name="FirstName"/>
                        <ext:RecordField Name="Surname"/>
                        <ext:RecordField Name="Initials" />
                        <ext:RecordField Name="EcdId" />
                        <ext:RecordField Name="Location" IsComplex="true"/>
                        <ext:RecordField Name="LocationName" Mapping="''+Location.LocationName"/>
                        <ext:RecordField Name="Department" IsComplex="true" />
                        <ext:RecordField Name="DepartmentName" Mapping="''+Department.DepartmentName" />
                        <ext:RecordField Name="MainRegisteredFirm" IsComplex="true" />
                        <ext:RecordField Name="MainRegFirmName" Mapping="''+MainRegisteredFirm.FirmName" />
                        <ext:RecordField Name="LineOfBusiness" IsComplex="true" />
                        <ext:RecordField Name="LineOfBusName" Mapping="''+LineOfBusiness.LineOfBusinessName"/>
                        <ext:RecordField Name="CostCentre" IsComplex="true" />
                        <ext:RecordField Name="CostCentreName" Mapping="''+CostCentre.CostCentreName"/>
                    </Fields>
                </ext:JsonReader>
            </Reader>
        </ext:Store>
        <ext:GridPanel ID="GridPanel1" runat="server" StoreID="PersonStore" Height="485" StripeRows="true">
                <ColumnModel ID="ColumnModel1" runat="server">
                    <Columns>
                        <ext:Column ColumnID="StatusCol" Header="Status" DataIndex="StatusName" Sortable="true" Groupable="true"/>
                        <ext:Column ColumnID="ECDStatusCol" Header="ECD status" DataIndex="EcdStatusName" Width="100" Sortable="true" Groupable="true" />
                        <ext:Column ColumnID="FullNameCol" Header="Name" DataIndex="FullName" Width="100" Sortable="true" Groupable="true">
                          <Renderer Fn="makelink" />
                        </ext:Column>
                        <ext:Column ColumnID="InitialsCol" Header="Initials" DataIndex="Initials" Width="30" Sortable="false" />
                        <ext:Column ColumnID="EcdIdCol" Header="ECD Id" DataIndex="EcdId" />
                        <ext:Column ColumnID="LocationCol" Header="Location" DataIndex="LocationName" Sortable="true" />
                        <ext:Column ColumnID="MainRegFirmNameCol" Header="Main registered firm" DataIndex="MainRegFirmName" Width="100" Sortable="true" />
                        <ext:Column ColumnID="DepartmentNameCol" Header="Department" DataIndex="DepartmentName" Width="100" Sortable="true" />
                        <ext:Column ColumnID="LineOfBusNameCol" Header="Line of business" DataIndex="LineOfBusName" Width="100" Sortable="true" />
                        <ext:Column ColumnID="CostCentreNameCol" Header="Cost centre" DataIndex="CostCentreName" Width="100" Sortable="true" />
                    </Columns>
                </ColumnModel>
                <BottomBar>
                <ext:PagingToolbar ID="PagingToolbar1" runat="server" PageSize="20" />
                </BottomBar>
                <SelectionModel>
                    <ext:RowSelectionModel ID="RowSelectionModel1" runat="server" />
                </SelectionModel>
                <View>
                  <ext:GroupingView runat="server" ID="GroupingView1" ForceFit="true">
                  </ext:GroupingView>
                </View>
    
    
        </ext:GridPanel>
    Here's the code to serialize my objects to the Store:
    
    
    
    List<Person> persons = PersonService.GetPersonList();
    this.PersonStore.DataSource = persons;
    this.PersonStore.DataBind();
    All quite simple and straightforward.

    If I don't include the '' concatenation in the Mapping attributes of the reader fields, then null complex objects cause the grid to sit in a continual loading state with the loading icon continually animated.

    Am I doing the right thing here? Do (potentially) null complex objects with associated mappings cause the sort of behaviour I'm seeing?

  2. #2

    RE: GridPanel, JSON store and Complex object properties

    Hi,

    Mapping is client side mapping only. It doesn't support complex mapping for JsonReader (but it can use XPath expression for XmlReader)


    You have to use ServerMapping. Why do you place quote inside Mapping?


  3. #3

    RE: GridPanel, JSON store and Complex object properties

    vladimir (2/2/2010)
    You have to use ServerMapping. Why do you place quote inside Mapping?
    Because otherwise the grid never renders whenever a complex field is null.

    Also, ext:RecordField doesn't have a ServerMapping attribute, just Mapping
  4. #4

    RE: GridPanel, JSON store and Complex object properties

    Hi,

    0.8.2 version contains ServerMapping.
    https://examples1.ext.net/#/GridPane...erver_Mapping/
  5. #5

    RE: GridPanel, JSON store and Complex object properties

    Ah, I'm using version 0.8.0.36080 of the Coolite assembly

Similar Threads

  1. JSON Serialize lost properties
    By marcelorosait in forum 1.x Help
    Replies: 5
    Last Post: Apr 17, 2012, 8:42 PM
  2. JSON Object to Store
    By Tbaseflug in forum 1.x Help
    Replies: 0
    Last Post: Oct 11, 2011, 8:44 PM
  3. Represent Complex Object on a Grid
    By nanosassa in forum 1.x Help
    Replies: 0
    Last Post: Sep 03, 2009, 1:38 PM
  4. Send complex object to AjaxMethod
    By glenh in forum 1.x Help
    Replies: 2
    Last Post: Aug 13, 2009, 10:01 AM
  5. [CLOSED] Binding List(of Object) Parsing properties
    By CMA in forum 1.x Legacy Premium Help
    Replies: 3
    Last Post: Jul 24, 2009, 7:25 AM

Posting Permissions