View Full Version : GridPanel, JSON store and Complex object properties

Feb 02, 2010, 11:43 AM
I'm persisting my app's object list to a Store which supplies a GridPanel as per below:

<ext:Store runat="server" ID="PersonStore">
<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"/>
<ext:GridPanel ID="GridPanel1" runat="server" StoreID="PersonStore" Height="485" StripeRows="true">
<ColumnModel ID="ColumnModel1" runat="server">
<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 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" />
<ext:PagingToolbar ID="PagingToolbar1" runat="server" PageSize="20" />
<ext:RowSelectionModel ID="RowSelectionModel1" runat="server" />
<ext:GroupingView runat="server" ID="GroupingView1" ForceFit="true">


Here's the code to serialize my objects to the Store:

List<Person> persons = PersonService.GetPersonList();
this.PersonStore.DataSource = persons;

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?

Feb 02, 2010, 12:24 PM

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?

Feb 02, 2010, 12:41 PM
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

Feb 02, 2010, 12:56 PM

0.8.2 version contains ServerMapping.

Feb 02, 2010, 1:00 PM
Ah, I'm using version of the Coolite assembly