I have an object that has two complex subobjects that are references to other objects.
I want the Grid to allow me to create, edit and delete this object. I have utilized the GridDropDownColumn
Of course this doesn't work because when editing this the GridDropDownColumn doesn't return the Server object it returns the ServerID (int).
What is the best way to accomplish what I want? Any suggestions?
I have tried creating a DeployedServerID property that would grab the object when passed an id from the dropdown. But then I get a OpenAccess error that two different ObjectScopes tried to manage the same object.
Thanks,
Josh
[Telerik.OpenAccess.Persistent(IdentityField = "deploymentID")] |
public class Deployment |
{ |
enum DeploymentStatus { Offline = 0, Running = 1, Deploying = 2 }; |
private int deploymentID; |
public int DeploymentID |
{ |
get { return deploymentID; } |
set { deploymentID = value; } |
} |
private Application deployedApplication; |
public Application DeployedApplication |
{ |
get { return deployedApplication; } |
set { deployedApplication = value; } |
} |
private Server deployedServer; |
public Server DeployedServer |
{ |
get { return deployedServer; } |
set { deployedServer = value; } |
} |
... |
I want the Grid to allow me to create, edit and delete this object. I have utilized the GridDropDownColumn
<Columns> |
<telerik:GridBoundColumn DataField="DeploymentID" DataType="System.Int32" HeaderText="DeploymentID" ReadOnly="True" SortExpression="DeploymentID" UniqueName="DeploymentID"> |
</telerik:GridBoundColumn> |
<telerik:GridDropDownColumn DataField="DeployedServer" HeaderText="Server" UniqueName="DeployedServer" DropDownControlType="DropDownList" DataSourceID="odsServers" ListTextField="ServerName" ListValueField="ServerID"></telerik:GridDropDownColumn> |
<telerik:GridBoundColumn DataField="BuildServerURI" HeaderText="BuildServerURI" SortExpression="BuildServerURI" UniqueName="BuildServerURI"> |
</telerik:GridBoundColumn> |
<telerik:GridBoundColumn DataField="CurrentBuild" DataType="System.Int32" HeaderText="CurrentBuild" SortExpression="CurrentBuild" UniqueName="CurrentBuild"> |
</telerik:GridBoundColumn> |
<telerik:GridBoundColumn DataField="Location" HeaderText="Location" SortExpression="Location" UniqueName="Location"> |
</telerik:GridBoundColumn> |
<telerik:GridTemplateColumn DataField="Application" UniqueName="TemplateColumn"> |
</telerik:GridTemplateColumn> |
</Columns> |
Of course this doesn't work because when editing this the GridDropDownColumn doesn't return the Server object it returns the ServerID (int).
What is the best way to accomplish what I want? Any suggestions?
I have tried creating a DeployedServerID property that would grab the object when passed an id from the dropdown. But then I get a OpenAccess error that two different ObjectScopes tried to manage the same object.
private Server deployedServer; |
public Server DeployedServer |
{ |
get { return deployedServer; } |
set { deployedServer = value; } |
} |
public int DeployedServerID |
{ |
get |
{ |
if (deployedServer == null) |
return -1; |
else |
return deployedServer.ServerID; |
} |
set |
{ |
deployedServer = (from servers in DataModel.ObjectScope().Extent<Server>() where servers.ServerID == value select servers).First<Server>(); |
} |
} |
Thanks,
Josh