I've bound my grid to an entity collection derived from a View. The view is self referencing and I'd like the grid to represent that parent-child relationship. The top level seems to acting correctly, but when I try and expand a top level node, I get this error.
"Parent table relation set, but no corresponding data-key name found."
I've checked all the obvious, but alas, I can't find the problem.
Any help or ideas would be greatly appreciated..
"Parent table relation set, but no corresponding data-key name found."
I've checked all the obvious, but alas, I can't find the problem.
<telerik:RadGrid runat="server" id="grdClients" |
OnNeedDataSource="grdClients_NeedDataSource" |
Skin="Default2006" |
AutoGenerateColumns="False" |
AllowPaging ="True" |
AllowSorting="True" |
PageSize="8" |
GridLines="None" |
ShowStatusBar="False" |
DataKeyNames="Id, SuperClientId" > |
<ExportSettings> |
<Excel Format="Html" /> |
</ExportSettings> |
<PagerStyle Mode="NextPrevAndNumeric"></PagerStyle> |
<ClientSettings AllowExpandCollapse="true" /> |
<MasterTableView> |
<SelfHierarchySettings ParentKeyName="Id" KeyName="SuperClientId" /> |
<Columns> |
<telerik:GridHyperLinkColumn |
DataTextField="Id" |
DataTextFormatString="edit" |
UniqueName="colEditbasePage" |
DataNavigateUrlFormatString="editClient.aspx?id={0}" |
DataNavigateUrlFields="id"> |
</telerik:GridHyperLinkColumn> |
<telerik:GridHyperLinkColumn |
DataTextField="Id" |
DataTextFormatString="deactivate" |
UniqueName="colDeactivateClient" |
DataNavigateUrlFormatString="?deactivateid={0}" |
DataNavigateUrlFields="Id"> |
</telerik:GridHyperLinkColumn> |
<telerik:GridBoundColumn |
DataField="CompanyName" |
DataType="System.String" |
HeaderText="First Name" |
SortExpression="CompanyName" |
UniqueName="colCompanyName" > |
</telerik:GridBoundColumn> |
<telerik:GridBoundColumn |
DataField="City" |
DataType="System.String" |
HeaderText="City" |
SortExpression="City" |
UniqueName="colCity" > |
</telerik:GridBoundColumn> |
<telerik:GridBoundColumn |
DataField="Country" |
DataType="System.String" |
HeaderText="Country" |
SortExpression="Country" |
UniqueName="colCountry" > |
</telerik:GridBoundColumn> |
<telerik:GridTemplateColumn HeaderText="Roles I fill"> |
<ItemTemplate> |
<table cellpadding="1" cellspacing="1" class="customTable"> |
<tr> |
<td style="width: 50%"> |
<%# getRoleIndicator((int)DataBinder.Eval(Container.DataItem, "Id"), Settings.Default.role_clientCGC)%> |
</td> |
<td style="width: 50%"> |
<%# getRoleIndicator((int)DataBinder.Eval(Container.DataItem, "Id"), Settings.Default.role_clientCC)%> |
</td> |
</tr> |
</table> |
</ItemTemplate> |
</telerik:GridTemplateColumn> |
<telerik:GridBoundColumn |
DataField="NumOfRequestsBought" |
DataType="System.Int32" |
HeaderText="Number of Requests Purchased" |
SortExpression="NumOfRequestsBought" |
UniqueName="colNumOfRequestsBought" > |
</telerik:GridBoundColumn> |
<telerik:GridBoundColumn |
DataField="NumOfRequestsUsed" |
DataType="System.Int32" |
HeaderText="Number of Requests Used" |
SortExpression="NumOfRequestsUsed" |
UniqueName="colNumOfRequestsUsed" > |
</telerik:GridBoundColumn> |
<telerik:GridCheckBoxColumn |
DataField="PurchasedApprovals" |
HeaderText="Purchased Approvals" |
AllowSorting="true" |
UniqueName="colPurchasedApprovals" > |
</telerik:GridCheckBoxColumn> |
<telerik:GridCheckBoxColumn |
DataField="PurchasedAgreements" |
HeaderText="Purchased Agreements" |
AllowSorting="true" |
UniqueName="colPurchasedAgreements" > |
</telerik:GridCheckBoxColumn> |
</Columns> |
</MasterTableView> |
</telerik:RadGrid> |
protected void Page_Load(object sender, EventArgs e) |
{ |
if (!Page.IsPostBack) |
{ |
Page.Title = "GlobeSpec | clients"; |
Page.Form.DefaultFocus = this.txbFilterGrid.ClientID; |
Page.Form.DefaultButton = this.btnFilterGrid.UniqueID; |
grdClients.MasterTableView.FilterExpression = "SuperClientID = 0 OR SuperClientID IS NULL"; |
} |
} |
protected void cmdExcel_Click(object sender, EventArgs e) |
{ |
this.grdClients.ExportSettings.ExportOnlyData = true; |
this.grdClients.ExportSettings.IgnorePaging = true; |
this.grdClients.MasterTableView.ExportToExcel(); |
} |
protected void grdClients_NeedDataSource(object source, GridNeedDataSourceEventArgs e) |
{ |
this.grdClients.DataSource = null; |
VClientsGridCollection coll = new VClientsGridCollection(); |
coll.LoadAll(); |
if (!string.IsNullOrEmpty(this.txbFilterGrid.Text.Trim())) |
{ |
//coll.Filter += " AND CompanyName Like '" + this.txbFilterGrid.Text.Trim() + @"%'"; |
coll.Filter = "CompanyName Like '" + this.txbFilterGrid.Text.Trim() + @"%'"; |
} |
coll.Sort = "CompanyName"; |
this.grdClients.DataSource = coll; |
} |
protected string getRoleIndicator(int clientId, string roleName) |
{ |
Person me = (Person) Session["User"]; |
l = new Lookup(); |
l.Query.Where(l.Query.LookupName.Like(roleName.Trim())).Select("Id"); |
l.Query.Load(); |
pc = new PersonClient(); |
pc.Query.Where(pc.Query.ClientId.Equal(clientId), |
pc.Query.RoleId.Equal(l.Id), |
pc.Query.PersonId.Equal(me.Id)); |
if(pc.Query.Load()) |
{ |
if (roleName.Equals(Settings.Default.role_clientCGC.ToString())) |
{ |
return "CGC"; |
} |
else if (roleName.Equals(Settings.Default.role_clientCC.ToString())) |
{ |
return "CC"; |
} |
} |
return string.Empty; |
} |
protected void btnFilterGrid_Click(object sender, EventArgs e) |
{ |
this.grdClients.DataSource = null; |
VClientsGridCollection coll = new VClientsGridCollection(); |
coll.LoadAll(); |
if (!string.IsNullOrEmpty(this.txbFilterGrid.Text.Trim())) |
{ |
coll.Filter = "CompanyName Like '" + this.txbFilterGrid.Text.Trim() + @"%'"; |
} |
coll.Sort = "CompanyName"; |
this.grdClients.DataSource = coll; |
this.grdClients.DataBind(); |
} |
Any help or ideas would be greatly appreciated..