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

Problem with grouping in radGrid

6 Answers 409 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Zach Tindall
Top achievements
Rank 1
Zach Tindall asked on 14 Apr 2010, 05:45 PM
Hi,

I have a problem with grouping in a radGrid.  When I try to add the grouping, I get the error message "Field xxx not found in the source table".  However, when I remove the GroupByExpressions, the grid populates correctly with the field that was "not found" when the GroupByExpressions were present.  I am using a needDataSource to bind my data as suggested in a previous post since I am pulling the data from an api.  Any help would be greatly apreciated.
-Z

aspx
<telerik:RadGrid ID="dgFeatures" runat="server" GridLines="None" AutoGenerateColumns="False" AllowFilteringByColumn="True"   
            AllowPaging="True" AllowSorting="True" ShowGroupPanel="True" ShowFooter="True" EnableLinqExpressions="false" > 
        <ClientSettings AllowRowsDragDrop="true">  
            <Selecting AllowRowSelect="True" /> 
        </ClientSettings> 
        <MasterTableView GroupLoadMode="Client" ShowGroupFooter="True" allowmulticolumnsorting="True" pagesize="100"  DataKeyNames="Id, Rank, Est,Priority ">  
            <RowIndicatorColumn Visible="False">  
            <HeaderStyle Width="20px"></HeaderStyle> 
            </RowIndicatorColumn> 
            <ExpandCollapseColumn Visible="False">  
            <HeaderStyle Width="19px"></HeaderStyle> 
            </ExpandCollapseColumn> 
            <Columns> 
 
                <telerik:GridBoundColumn SortExpression="Name" DataField="Name" HeaderText="Feature"   
                    UniqueName="Feature" ConvertEmptyStringToNull="False" /> 
 
                <telerik:GridBoundColumn SortExpression="Rank" DataField="Rank" HeaderText="Rank"   
                    UniqueName="Rank"/>  
 
                <telerik:GridBoundColumn DataField="ID" HeaderText="Id" UniqueName="Id"   
                    Visible="False"/>  
 
                <telerik:GridBoundColumn DataField="Priority" HeaderText="Priority"   
                    UniqueName="Priority" /> 
 
                <telerik:GridBoundColumn DataField="Backlog"   
                    HeaderText="Backlog Candidate" UniqueName="BacklogCandidate" /> 
 
                <telerik:GridBoundColumn FooterText="Total Points" DataField="PlanEst"   
                    HeaderText="Tech Points" UniqueName="TechPoints" /> 
 
                <telerik:GridBoundColumn DataField="EstRelease" 
                    HeaderText="Est Release" UniqueName="EstRelease" /> 
 
            </Columns> 
            <GroupByExpressions> 
                <telerik:GridGroupByExpression> 
                    <GroupByFields> 
                        <telerik:GridGroupByField FieldName="EstRelease" /> 
                    </GroupByFields> 
                    <SelectFields> 
                        <telerik:GridGroupByField FieldName="EstRelease" HeaderText="Estimated Release Date" /> 
                    </SelectFields> 
                </telerik:GridGroupByExpression> 
            </GroupByExpressions> 
        </MasterTableView> 
        <HeaderContextMenu EnableAutoScroll="True"></HeaderContextMenu> 
    </telerik:RadGrid> 

vb
Private Sub dgFeatures_NeedDataSource1(ByVal source As Object, ByVal e As Telerik.Web.UI.GridNeedDataSourceEventArgs) Handles dgFeatures.NeedDataSource  
        Me.dgFeatures.DataSource = Me.records  
    End Sub 

6 Answers, 1 is accepted

Sort by
0
Pavlina
Telerik team
answered on 15 Apr 2010, 12:45 PM
Hello Zach,

I reviewed the setup, and the code looks correct. If the issue persists, please isolate the issue in a simple working project and attach it to regular support ticket. This way we will be able to reproduce the problem locally and provide a solution.

Thank you.

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
Michael
Top achievements
Rank 1
answered on 17 May 2010, 06:26 PM
I'm having this same issue.  The problem appears that I'm using a stored procedure to get my dataset.  The stored proc changes the name (aliases) the field.  I'm  also using auto generated columns.  So if the stored proc is some thing like  Select mbucode [MBU Code], casecode [Case Code].... from xtable where........   Grouping on MBU Code will fail and return the following error:
Field MBU not found in the source table. Please check the expression syntax.  It appears that the RadGrid can't handle the space in the field name. 

If I modify the stored proc to Select mbucode [mbucode], casecode [casecoe].... from xtable where........  Everything works fine.

The problem is I can't modify the stored proc permenantly it needs to have the fields with the spaces for other processes that use it.  How can I handle this on my end so the RadGrid will allow grouping ???

BTW, sorting works fine
0
Pavlina
Telerik team
answered on 18 May 2010, 02:01 PM
Hello Michael,

The group by expression relies on the presence of the Column DataField in the DataSource. After you modify the stored proc to Select mbucode [mbucode], casecode [casecode], everything is working fine, because the DataField property should contains one word only.

Kind regards,
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
Terry Hoiness
Top achievements
Rank 1
answered on 25 Oct 2010, 11:04 PM
That's not always the case, however.  My organization runs reports that auto generates fields and headers based on the associated view's outputted field names (the whole purpose behind the ability to autogenerate tables).  Under these circumstances, this feature is broken, as two word fields are the rule, and not the exception.

There is a definite need for support of field name aliases that contain spaces like "lastname as [Last Name]"
0
Pavlina
Telerik team
answered on 26 Oct 2010, 02:06 PM
Hello Terry,

RadGrid grouping works only with unique column names without space. Please check out the following Forum link which discusses the same issue.
http://www.telerik.com/community/forums/aspnet/grid/why-can-t-i-group-by-fields-with-a-space-in-the-field-name.aspx

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
Kevin
Top achievements
Rank 1
answered on 19 Jul 2011, 06:25 PM
This may work for some people and was easy to use.  This is the normal GetDataTable function that is suggested by telerik with a small addition marked with comments.

Public
Function GetDataTable(ByVal query As String) As DataTable
  
        Dim conn1 As SqlConnection
        conn1 = cls_utils.OpenAFConn()
  
        Dim adapter As SqlDataAdapter = New SqlDataAdapter
        adapter.SelectCommand = New SqlCommand(query, conn1)
        Dim table1 As New DataTable
        conn1.Open()
        Try
            adapter.Fill(table1)
'ADDED REMOVAL OF SPACE with replacement of underscore
            For Each column As DataColumn In table1.Columns
  
                table1.Columns(column.ColumnName).ColumnName = Replace(column.ColumnName, " ", "_")
  
            Next
'END OF ADDITION
        Finally
            conn1.Close()
        End Try
        Return table1
    End Function


I then added another sub to remove the underscore from the header text
Protected Sub grid_column_created(ByVal sender As Object, ByVal e As GridColumnCreatedEventArgs) Handles grid_adhoc_viewer.ColumnCreated
    e.Column.HeaderText = Replace(e.Column.HeaderText, "_", " ")
End Sub
Tags
Grid
Asked by
Zach Tindall
Top achievements
Rank 1
Answers by
Pavlina
Telerik team
Michael
Top achievements
Rank 1
Terry Hoiness
Top achievements
Rank 1
Kevin
Top achievements
Rank 1
Share this question
or