Jan 14, 2009, 6:29 PM
objects with reference type properties in GridPanel
Hi, I'm trying to get working GridPanel with objects that contains class type properties.Here is code snipsets:
my simplyfied dto's are here:
[CODE]
abstract public class BaseDto : IDto
{
private int id;
private int version;
public int Id
{
get { return id; }
set { id = value; }
}
public int Version
{
get { return version; }
set { version = value; }
}
public bool IsTransient
{
get
{
return id == default(int);
}
}
}
[CODE]
my working time dto, that contains reference to resource dto:
[CODE]
public class WorkingTimeDto : BaseDto
{
private string description;
private WorkingTimeStatus status;
private ResourceDto resource;
public string Description
{
get { return description; }
set { description = value; }
}
public WorkingTimeStatus Status
{
get { return status; }
set { status = value; }
}
public ResourceDto Resource
{
get { return resource; }
set { resource = value; }
}
}
[CODE]
and resource dto:
[CODE]
public class ResourceDto : BaseDto
{
private double hourlyRate;
public double HourlyRate
{
get { return hourlyRate; }
set { hourlyRate = value; }
}
}
[CODE]
I have configured main store for GridPanel that shows working time dtos. Store code:
[CODE]
<ext:Store ID="WorkingTimeStore" runat="server" OnRefreshData="GetWorkingTimes" OnBeforeRecordUpdated="BeforeWorkingTimeUpdate"
OnBeforeRecordInserted="BeforeWorkingTimeInsert" OnBeforeRecordDeleted="BeforeWorkingTimeDelete"
RemoteSort="true">
<Proxy>
<ext:DataSourceProxy />
</Proxy>
<Reader>
<ext:JsonReader ReaderID="Id">
<Fields>
<ext:RecordField Name="Id">
</ext:RecordField>
<ext:RecordField Name="Version">
</ext:RecordField>
<ext:RecordField Name="Resource">
</ext:RecordField>
<ext:RecordField Name="Payable">
</ext:RecordField>
<ext:RecordField Name="Status">
</ext:RecordField>
<ext:RecordField Name="Description">
</ext:RecordField>
</Fields>
</ext:JsonReader>
</Reader>
<AutoLoadParams>
<ext:Parameter Name="start" Value="0" Mode="Raw" />
<ext:Parameter Name="limit" Value="10" Mode="Raw" />
</AutoLoadParams>
<SortInfo Field="Id" Direction="ASC" />
<Listeners>
<LoadException Handler="Ext.Msg.alert('Working Times - Load failed', e.message || e )" />
</Listeners>
</ext:Store>
[CODE]
and here is grid panel:
[CODE]
<ext:GridPanel ID="GridPanel1" Title="Time" runat="server" StoreID="WorkingTimeStore"
AutoExpandColumn="Description" AutoHeight="true" Width="800" ButtonAlign="Center">
<ColumnModel ID="ColumnModel2" runat="server">
<Columns>
<ext:Column DataIndex="Resource" Header="Resources" Width="200">
<Renderer Fn="resourceName" />
<Editor>
<ext:ComboBox runat="server" StoreID="ResourcesStore" Editable="false" DisplayField="FullName"
ValueField="Id" TriggerAction="All" Mode="Local">
</ext:ComboBox>
</Editor>
</ext:Column>
<ext:Column ColumnID="Description" DataIndex="Description" Header="Notes">
<Editor>
<ext:TextField ID="TextField6" runat="server">
</ext:TextField>
</Editor>
</ext:Column>
</Columns>
</ColumnModel>
</ext:GridPanel>
[CODE]
Combobox is configured to use another ResourcesStore, that contains dto's another that ResourceDto - only with 2 properties - Id and full name.Everything is working for me except when I first time load grid resource columns are empty. As understood this is because I need to provide integer Id in some way for combobox column or I'm something misunderstanding? If I'm right, then how I could do that? Have seen that RecordField contains property Converter. I have tried it with JavaScript function with one argument value, but this value always are string with one space.
Thanks,
Z.
my simplyfied dto's are here:
[CODE]
abstract public class BaseDto : IDto
{
private int id;
private int version;
public int Id
{
get { return id; }
set { id = value; }
}
public int Version
{
get { return version; }
set { version = value; }
}
public bool IsTransient
{
get
{
return id == default(int);
}
}
}
[CODE]
my working time dto, that contains reference to resource dto:
[CODE]
public class WorkingTimeDto : BaseDto
{
private string description;
private WorkingTimeStatus status;
private ResourceDto resource;
public string Description
{
get { return description; }
set { description = value; }
}
public WorkingTimeStatus Status
{
get { return status; }
set { status = value; }
}
public ResourceDto Resource
{
get { return resource; }
set { resource = value; }
}
}
[CODE]
and resource dto:
[CODE]
public class ResourceDto : BaseDto
{
private double hourlyRate;
public double HourlyRate
{
get { return hourlyRate; }
set { hourlyRate = value; }
}
}
[CODE]
I have configured main store for GridPanel that shows working time dtos. Store code:
[CODE]
<ext:Store ID="WorkingTimeStore" runat="server" OnRefreshData="GetWorkingTimes" OnBeforeRecordUpdated="BeforeWorkingTimeUpdate"
OnBeforeRecordInserted="BeforeWorkingTimeInsert" OnBeforeRecordDeleted="BeforeWorkingTimeDelete"
RemoteSort="true">
<Proxy>
<ext:DataSourceProxy />
</Proxy>
<Reader>
<ext:JsonReader ReaderID="Id">
<Fields>
<ext:RecordField Name="Id">
</ext:RecordField>
<ext:RecordField Name="Version">
</ext:RecordField>
<ext:RecordField Name="Resource">
</ext:RecordField>
<ext:RecordField Name="Payable">
</ext:RecordField>
<ext:RecordField Name="Status">
</ext:RecordField>
<ext:RecordField Name="Description">
</ext:RecordField>
</Fields>
</ext:JsonReader>
</Reader>
<AutoLoadParams>
<ext:Parameter Name="start" Value="0" Mode="Raw" />
<ext:Parameter Name="limit" Value="10" Mode="Raw" />
</AutoLoadParams>
<SortInfo Field="Id" Direction="ASC" />
<Listeners>
<LoadException Handler="Ext.Msg.alert('Working Times - Load failed', e.message || e )" />
</Listeners>
</ext:Store>
[CODE]
and here is grid panel:
[CODE]
<ext:GridPanel ID="GridPanel1" Title="Time" runat="server" StoreID="WorkingTimeStore"
AutoExpandColumn="Description" AutoHeight="true" Width="800" ButtonAlign="Center">
<ColumnModel ID="ColumnModel2" runat="server">
<Columns>
<ext:Column DataIndex="Resource" Header="Resources" Width="200">
<Renderer Fn="resourceName" />
<Editor>
<ext:ComboBox runat="server" StoreID="ResourcesStore" Editable="false" DisplayField="FullName"
ValueField="Id" TriggerAction="All" Mode="Local">
</ext:ComboBox>
</Editor>
</ext:Column>
<ext:Column ColumnID="Description" DataIndex="Description" Header="Notes">
<Editor>
<ext:TextField ID="TextField6" runat="server">
</ext:TextField>
</Editor>
</ext:Column>
</Columns>
</ColumnModel>
</ext:GridPanel>
[CODE]
Combobox is configured to use another ResourcesStore, that contains dto's another that ResourceDto - only with 2 properties - Id and full name.Everything is working for me except when I first time load grid resource columns are empty. As understood this is because I need to provide integer Id in some way for combobox column or I'm something misunderstanding? If I'm right, then how I could do that? Have seen that RecordField contains property Converter. I have tried it with JavaScript function with one argument value, but this value always are string with one space.
Thanks,
Z.