This is a migrated thread and some comments may be shown as answers.

Selfreferencing hierarchy error/bug

7 Answers 169 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Yeroon
Top achievements
Rank 2
Yeroon asked on 01 Feb 2010, 09:28 AM
Hello there,

I followed your selfreferencing hierarchy sample and ran into the following error:

System.Data.SyntaxErrorException: Syntax error in Lookup expression: Expecting keyword 'Parent' followed by a single column argument with possible relation qualifier: Parent[(<relation_name>)].<column_name>.

I set the EnableLinqExpressions to false, but that didn't help. Tried using different datasource implementation, but no help either.

Then I tried changing my Columnname in my objectdatasource (and corresponding MSSQL server table column) to MyParent instead of Parent. And then the problem went away.

So probably the grid is not accepting a parent - child relation defined with a column named Parent referencing the Keycolumn.

Using 2009, 3, 1314, 35 build.


7 Answers, 1 is accepted

Sort by
0
Pavlina
Telerik team
answered on 04 Feb 2010, 09:01 AM
Hello Yeroon,

Please refer to the project attached to the following forum thread, which elaborates on this matter. Give it a try and let me know if it helps to avoid this error.
http://www.telerik.com/community/forums/aspnet-ajax/grid/self-referencing-hierarchy-grid-issue.aspx

Greetings,
Pavlina
the Telerik team

Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Follow the status of features or bugs in PITS and vote for them to affect their priority.
0
Yeroon
Top achievements
Rank 2
answered on 04 Feb 2010, 10:31 AM
Hi,

Thanks for your response. It didn't help for me. It seems that calling my property/database field "Parent" causes this error. The grid must somehow interpret/parse the field based on this name. So it seems like its a sort of reserved word in RadGrid. When renaming the column to "MyParent" and corresponding class property in my class file it works OK.

/Yeroon
0
Pavlina
Telerik team
answered on 05 Feb 2010, 10:25 AM
Hello Yeroon,

Unfortunately, the provided information does not help us much in reproducing the error. I'm afraid we could not be of much help unless we reproduce the issue on our side. It will be best if you can open a support ticket and send us a simple running project (incl. DB backup) demonstrating the problem. In that way we can reproduce and pinpoint the problems you're facing on our side and provide a solution.

Looking forward for your reply.

All the best,
Pavlina
the Telerik team

Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Follow the status of features or bugs in PITS and vote for them to affect their priority.
0
Yeroon
Top achievements
Rank 2
answered on 09 Mar 2010, 04:37 PM
Sorry for the late response. I overlooked the thread since I solved the issue on my side. Its very easy to reproduce:

ASP page in a Telerik Web Application template:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="Default" %> 
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
 
<html xmlns="http://www.w3.org/1999/xhtml">  
<head runat="server">  
    <title></title>  
    <telerik:RadStyleSheetManager id="RadStyleSheetManager1" runat="server" /> 
</head> 
<body> 
    <form id="form1" runat="server">  
    <telerik:RadScriptManager ID="RadScriptManager1" runat="server">  
        <Scripts> 
            <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.Core.js" /> 
            <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQuery.js" /> 
        </Scripts> 
    </telerik:RadScriptManager> 
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">  
    </telerik:RadAjaxManager> 
    <div> 
        <telerik:RadGrid ID="rgMain" runat="server" AutoGenerateColumns="False" OnNeedDataSource="rgMain_NeedDataSource" 
        Skin="Office2007" ShowFooter="false" ShowStatusBar="true"   
        AllowSorting="true" AllowPaging="true" PageSize="30" EnableLinqExpressions="false" > 
        <MasterTableView DataKeyNames="Parent,OID" ClientDataKeyNames="OID" HierarchyDefaultExpanded="true" HierarchyLoadMode="Client" > 
            <SelfHierarchySettings ParentKeyName="Parent" KeyName="OID" /> 
            <Columns> 
                <telerik:GridBoundColumn DataField="OID" HeaderText="OID" Visible="true" UniqueName="OID">  
                </telerik:GridBoundColumn> 
                <telerik:GridBoundColumn DataField="Parent" HeaderText="Parent" Visible="true">  
                </telerik:GridBoundColumn> 
                <telerik:GridBoundColumn DataField="MyText" HeaderText="MyText" Visible="true">  
                </telerik:GridBoundColumn> 
            </Columns> 
        </MasterTableView> 
        <ClientSettings EnableRowHoverStyle="true" AllowExpandCollapse="true">  
            <ClientEvents OnRowSelected="openDetails" /> 
            <Selecting AllowRowSelect="true" /> 
        </ClientSettings> 
    </telerik:RadGrid> 
    </div> 
    </form> 
</body> 
</html> 


Code behind:

using System;  
using Telerik.Web.UI;  
 
public partial class Default : System.Web.UI.Page   
{  
    protected void Page_Load(object sender, EventArgs e)  
    {  
 
    }  
 
    protected void rgMain_NeedDataSource(object source, GridNeedDataSourceEventArgs e)  
    {  
        MyDataObject[] arrMdo = new MyDataObject[4];  
        MyDataObject mdo = new MyDataObject();  
        mdo.OID = 1;  
        mdo.Parent = null;  
        mdo.MyText = "Root";  
 
        arrMdo[0] = mdo;  
 
        mdo = new MyDataObject();  
        mdo.OID = 2;  
        mdo.Parent = 1;  
        mdo.MyText = "Sub 1";  
 
        arrMdo[1] = mdo;  
 
        mdo = new MyDataObject();  
        mdo.OID = 3;  
        mdo.Parent = 1;  
        mdo.MyText = "Sub 2";  
 
        arrMdo[2] = mdo;  
 
        mdo = new MyDataObject();  
        mdo.OID = 4;  
        mdo.Parent = 3;  
        mdo.MyText = "Sub Sub 1";  
 
        arrMdo[3] = mdo;  
 
        rgMain.DataSource = arrMdo;  
    }  
 
 
    public class MyDataObject  
    {  
        public int? OID { get; set; }  
        public int? Parent { get; set; }  
        public string MyText { get; set; }  
    }  
}  
 


Just run and see the error:

Server Error in '/' Application.  
--------------------------------------------------------------------------------  
 
Syntax error in Lookup expression: Expecting keyword 'Parent' followed by a single column argument with possible relation qualifier: Parent[(<relation_name>)].<column_name>.   
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.   
 
Exception Details: System.Data.SyntaxErrorException: Syntax error in Lookup expression: Expecting keyword 'Parent' followed by a single column argument with possible relation qualifier: Parent[(<relation_name>)].<column_name>.  
 
Source Error:   
 
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.    
 
Stack Trace:   
 
 
[SyntaxErrorException: Syntax error in Lookup expression: Expecting keyword 'Parent' followed by a single column argument with possible relation qualifier: Parent[(<relation_name>)].<column_name>.]  
   System.Data.ExpressionParser.Parse() +4820351  
   System.Data.DataExpression..ctor(DataTable table, String expression, Type type) +121  
   System.Data.DataView.set_RowFilter(String value) +153  
   Telerik.Web.UI.GridEnumerableFromDataView.PerformTransformation() +679  
   Telerik.Web.UI.GridEnumerableFromDataView.TransformEnumerable() +41  
   Telerik.Web.UI.GridTableView.GetEnumerator(Boolean useDataSource, GridEnumerableBase resolvedDataSource, ArrayList dataKeysArray) +171  
   Telerik.Web.UI.GridTableView.CreateControlHierarchy(Boolean useDataSource) +861  
   Telerik.Web.UI.GridTableView.CreateChildControls(IEnumerable dataSource, Boolean useDataSource) +782  
   System.Web.UI.WebControls.CompositeDataBoundControl.PerformDataBinding(IEnumerable data) +57  
   System.Web.UI.WebControls.DataBoundControl.OnDataSourceViewSelectCallback(IEnumerable data) +114  
   System.Web.UI.DataSourceView.Select(DataSourceSelectArguments arguments, DataSourceViewSelectCallback callback) +31  
   System.Web.UI.WebControls.DataBoundControl.PerformSelect() +142  
   Telerik.Web.UI.GridTableView.PerformSelect() +28  
   System.Web.UI.WebControls.BaseDataBoundControl.DataBind() +73  
   Telerik.Web.UI.GridTableView.DataBind() +351  
   Telerik.Web.UI.GridTableView.BindClone(GridTableView clone) +112  
   Telerik.Web.UI.GridItemBuilder.BindDetailTable(GridDataItem parentItem, GridTableView cloned) +88  
   Telerik.Web.UI.GridItemBuilder.BindDetailTables(GridDataItem parentItem, GridNestedViewItem detailItem) +181  
   Telerik.Web.UI.GridItemBuilder.CreateItems(GridGroupingContext group) +1472  
   Telerik.Web.UI.GridTableView.CreateItems(IEnumerator enumerator, GridColumn[] columns, ControlCollection controls) +187  
   Telerik.Web.UI.GridTableView.CreateControlHierarchy(Boolean useDataSource) +1573  
   Telerik.Web.UI.GridTableView.CreateChildControls(IEnumerable dataSource, Boolean useDataSource) +782  
   System.Web.UI.WebControls.CompositeDataBoundControl.PerformDataBinding(IEnumerable data) +57  
   System.Web.UI.WebControls.DataBoundControl.OnDataSourceViewSelectCallback(IEnumerable data) +114  
   System.Web.UI.DataSourceView.Select(DataSourceSelectArguments arguments, DataSourceViewSelectCallback callback) +31  
   System.Web.UI.WebControls.DataBoundControl.PerformSelect() +142  
   Telerik.Web.UI.GridTableView.PerformSelect() +28  
   System.Web.UI.WebControls.BaseDataBoundControl.DataBind() +73  
   Telerik.Web.UI.GridTableView.DataBind() +351  
   Telerik.Web.UI.RadGrid.DataBind() +165  
   Telerik.Web.UI.RadGrid.AutoDataBind(GridRebindReason rebindReason) +3868  
   Telerik.Web.UI.RadGrid.OnLoad(EventArgs e) +177  
   System.Web.UI.Control.LoadRecursive() +50  
   System.Web.UI.Control.LoadRecursive() +141  
   System.Web.UI.Control.LoadRecursive() +141  
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +627  
 
   
 
 
--------------------------------------------------------------------------------  
Version Information: Microsoft .NET Framework Version:2.0.50727.3603; ASP.NET Version:2.0.50727.3082  


When you replace all occurences in aspx and codebehind of Parent with MyParent, it will work with no problem.
0
Yeroon
Top achievements
Rank 2
answered on 16 Mar 2010, 12:03 PM
Hello.

I was wondering if you were able to reproduce this issue with the provided code in the post above.

Sincerely

/Yeroon
0
Accepted
Pavlina
Telerik team
answered on 19 Mar 2010, 11:34 AM
Hi Yeroon,

Thank you for the provided code. Indeed I was able to replicate the issue you are facing. It seems that the word "Parent" is internally used in self-referencing hierarchy grid, therefore you received this error. However, at this point the only workaround is to change the Parent DataField name.

I hope this helps.

Sincerely yours,
Pavlina
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Yeroon
Top achievements
Rank 2
answered on 22 Mar 2010, 09:50 AM
Hi Pavlina,

I know how to work around it :)

Consider it a bug report. It seems to me that having parent child relationship in data object with the name parent is not too uncommon.

/Yeroon
Tags
Grid
Asked by
Yeroon
Top achievements
Rank 2
Answers by
Pavlina
Telerik team
Yeroon
Top achievements
Rank 2
Share this question
or