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

GridDropDownColumn GroupByExpression error

3 Answers 33 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Delvis
Top achievements
Rank 1
Delvis asked on 06 Feb 2018, 05:34 PM

 I want to use a "GridDropDownColumn" column as shown in the example:

<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" />
        <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQueryInclude.js" />
    </scripts>
    </telerik:RadScriptManager>
         
        <telerik:RadGrid ID="RadGrid1" runat="server" AllowSorting="True" AllowPaging="True" DataSourceID="LinqDataSource1"
            AutoGenerateColumns="False" ShowGroupPanel="True" EnableHeaderContextMenu="True">
            <pagerstyle mode="NextPrevAndNumeric" />
             
            <ClientSettings AllowDragToGroup="True"/>
             
            <mastertableview commanditemdisplay="Top" datakeynames="ProductID" datasourceid="LinqDataSource1" editmode="InPlace">
                <Columns>
                     
                    <telerik:GridBoundColumn DataField="ProductName" HeaderText="ProductName" SortExpression="ProductName" UniqueName="ProductName"/>
 
                    <telerik:GridDropDownColumn DataField="CategoryID" DataType="System.Int32" HeaderText="Category"
                        UniqueName="CategoryID" DataSourceID="LinqDataSource2" ListValueField="CategoryID" ListTextField="CategoryName"
                        SortExpression="Categories.CategoryName" GroupByExpression="Categories.CategoryName [Category] Group By Categories.CategoryName"/>
 
                    <telerik:GridBoundColumn DataField="UnitPrice" HeaderText="UnitPrice" SortExpression="UnitPrice" UniqueName="UnitPrice"/>
 
                    <telerik:GridBoundColumn DataField="UnitsInStock" HeaderText="UnitsInStock" SortExpression="UnitsInStock" UniqueName="UnitsInStock"/>
 
                    <telerik:GridCheckBoxColumn DataField="Discontinued" HeaderText="Discontinued" SortExpression="Discontinued" UniqueName="Discontinued"/>
                     
                </Columns>
            </mastertableview>
        </telerik:RadGrid>
 
    <asp:LinqDataSource ID="LinqDataSource1" runat="server" ContextTypeName="TelerikWebSample.DataClasses1DataContext"
        EntityTypeName="" TableName="Products"/>
 
    <asp:LinqDataSource ID="LinqDataSource2" runat="server" ContextTypeName="TelerikWebSample.DataClasses1DataContext"
        EntityTypeName="" TableName="Categories" Select="new (CategoryID, CategoryName)"/>
</form>

When grouped by that column I get the following error:

 

"Field Categories.CategoryName not found in the source table. Please check the expression syntax."

However, when you add a new column that is not visible with the "Categories.CategoryName" field, everything works perfectly.

<telerik:GridBoundColumn DataField="Categories.CategoryName" UniqueName="CategoryName" Visible="False"/>

What is this about?.

Is there a solution to avoid unnecessarily using this non-visible column?

 

Thanks for the help.

 

Delvis

 

3 Answers, 1 is accepted

Sort by
0
Eyup
Telerik team
answered on 09 Feb 2018, 09:16 AM
Hello Delvis,

You can try setting one of these properties to the missing field:
<telerik:GridDropDownColumn DataField="" ListDataMember="">

Alternatively, you can try adding it to the following collection:
<MasterTableView ... GroupsDefaultExpanded="false">

I hope this will prove helpful.

Regards,
Eyup
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Delvis
Top achievements
Rank 1
answered on 09 Feb 2018, 08:51 PM

Hi Eyup:

The suggestion does not solve the problem.

I am using Linq To SQL.

In the supplied example, DataField = "CategoryID" and it is not necessary to set the ListDataMember property

I set GroupsDefaultExpanded = "false" and the error persists.

I do not understand, if the property SortExpression = "Categories.CategoryName" and sorts correctly, why when I set the property GroupByExpression = "Categories.CategoryName [Category] Group By Categories.CategoryName" does not find the field "Categories.CategoryName".

This is the error:

 

Error de servidor en la aplicación '/'.

Field Categories.CategoryName not found in the source table. Please check the expression syntax.
Descripción: Excepción no controlada al ejecutar la solicitud Web actual. Revise el seguimiento de la pila para obtener más información acerca del error y dónde se originó en el código.

Detalles de la excepción: Telerik.Web.UI.GridGroupByException: Field Categories.CategoryName not found in the source table. Please check the expression syntax.

Error de código fuente:
Se ha generado una excepción no controlada durante la ejecución de la solicitud Web actual. La información sobre el origen y la ubicación de la excepción pueden identificarse utilizando la excepción del seguimiento de la pila siguiente.

Seguimiento de la pila:
 [GridGroupByException: Field Categories.CategoryName not found in the source table. Please check the expression syntax.]   Telerik.Web.UI.GridDataSetHelper.CreateGroupByTable(DataTable SourceTable, GridTableView view) +439   Telerik.Web.UI.GridDataSetHelper.CalcGroupByTables(GridTableView gridTableView, DataTable SourceTable, String RowFilter, Int32 FirstIndex, Int32 LastIndex, Boolean applyPaging, Boolean isCustomPaging) +37   Telerik.Web.UI.GridEnumerableFromDataView.PerformTransformation() +2547   Telerik.Web.UI.GridEnumerableFromDataView.TransformEnumerable() +18   Telerik.Web.UI.GridTableView.GetEnumerator(Boolean useDataSource, GridEnumerableBase resolvedDataSource, ArrayList dataKeysArray, Boolean shouldClearDataKeys) +131   Telerik.Web.UI.GridTableView.CreateControlHierarchy(Boolean useDataSource) +1207   Telerik.Web.UI.GridTableView.CreateChildControls(IEnumerable dataSource, Boolean useDataSource) +1099   System.Web.UI.WebControls.CompositeDataBoundControl.PerformDataBinding(IEnumerable data) +67   System.Web.UI.WebControls.DataBoundControl.OnDataSourceViewSelectCallback(IEnumerable data) +128   System.Web.UI.DataSourceView.Select(DataSourceSelectArguments arguments, DataSourceViewSelectCallback callback) +34   System.Web.UI.WebControls.DataBoundControl.PerformSelect() +143   Telerik.Web.UI.GridTableView.PerformSelect() +16   System.Web.UI.WebControls.BaseDataBoundControl.DataBind() +74   Telerik.Web.UI.GridTableView.DataBind() +284   Telerik.Web.UI.GridTableView.BindAllInHierarchyLevel() +47   Telerik.Web.UI.RadGrid.RaisePostBackEvent(String eventArgument) +7600   System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +15   System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +9754214   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3562


Información de versión: Versión de Microsoft .NET Framework:4.0.30319; Versión ASP.NET:4.6.1087.0

 

 

Regards,

 

Delvis

0
Eyup
Telerik team
answered on 14 Feb 2018, 02:19 PM
Hello Delvis,

In this case I suggest that you open a formal support thread and send us a isolated runnable version of the project for further investigation. This will enable us to replicate the issue locally and provide more accurate and precise suggestions.

Regards,
Eyup
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
Grid
Asked by
Delvis
Top achievements
Rank 1
Answers by
Eyup
Telerik team
Delvis
Top achievements
Rank 1
Share this question
or