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

Grouping Template and Bound columns

11 Answers 494 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jes
Top achievements
Rank 1
Jes asked on 07 Jun 2009, 10:19 PM
We have a RadGrid that has mostly bound columns but a few template columns.  When grouping by any or all of the bound columns and then the template columns, there are no issues.  However, when choosing a template column first and then a bound column, we always get the error "An error occured adding a relation to DataRelationCollection. Please, make sure you have configured the expressions properly - both GroupByFields and SelectFields are required".

11 Answers, 1 is accepted

Sort by
0
Pavlina
Telerik team
answered on 08 Jun 2009, 04:56 PM
Hello Jes,

In order to display the grid grouped by the template column, you will need to add a group by expression for it too.Expressions can be defined by assigning Expression property and/or managing the items in SelectFields or GroupByFields collections. It is not required to use both of them.

Find more information about group by expression in the following articles:
GridGroupByExpression Class
Declarative definition
Programmatic definition

Regards,
Pavlina
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Jes
Top achievements
Rank 1
answered on 08 Jun 2009, 04:57 PM
We have a Group By Expression defined for the template columns and we still experience this error when trying to group with one of them.
0
Pavlina
Telerik team
answered on 09 Jun 2009, 08:14 AM
Hello Jes,

From the provided information I am not able to determine what have caused the unexpected behavior. At this point in order to progress in the resolution of this problem, it will be best if you open a formal support ticket and send me a small runnable application which would allow me to track the issue locally.

As soon as I do, I will get back to you with additional information/suggestions.

Sincerely yours,
Pavlina
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
TAD RHODES
Top achievements
Rank 1
answered on 16 Nov 2009, 05:26 PM
I to have this exact issue.  I have a one template column with 6 other bound columns.  I have this statement on the template column GroupByExpression="Group By ShortSKU".
I also have the showexport buttons turned on.

If you drag the template column into the group panel it groups just fine.  However, when you try to export to word or excel it'll throw the relation to DataRelationCollection error. 

However, if you first drag a bound column then export; no problems, meaning it exports correctly without any errors.

Definitely something funky when first use the template column.
0
Pavlina
Telerik team
answered on 17 Nov 2009, 04:20 PM
Hi TAD,

If the issue persists, please send us  the problematic code for further investigation. Thus I could be able to find a quick resolution of this issue.

Greetings,
Pavlina
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
TAD RHODES
Top achievements
Rank 1
answered on 17 Nov 2009, 06:40 PM
Not a problem.  I'll place it in the format code block; let me know if you need anything else.

<script type="text/javascript"
            function onRequestStart(sender, args) 
            { 
                if (args.get_eventTarget().indexOf("ExportToExcelButton") >= 0 || 
                    args.get_eventTarget().indexOf("ExportToWordButton") >= 0 || 
                    args.get_eventTarget().indexOf("ExportToPdfButton") >= 0 || 
                    args.get_eventTarget().indexOf("ExportToCsvButton") >= 0) 
                { 
 
                    args.set_enableAjax(false); 
                } 
            } 
        </script> 
 
<telerik:RadGrid ID="gridMissingProductData"  
                         runat="server" 
                         AutoGenerateColumns="false" 
                         PageSize="20" 
                         PagerStyle-AlwaysVisible="true" 
                         PagerStyle-Mode="NextPrevNumericAndAdvanced" 
                         AllowPaging="true" 
                         AllowMultiRowSelection="true" 
                         AllowSorting="true" 
                         ShowGroupPanel="true" 
                         OnItemCommand="gridMissingProductData_ItemCommand" 
                         OnItemDataBound="gridMissingProductData_ItemDataBound" 
                         ShowFooter="true"
                         <ExportSettings></ExportSettings
                         <MasterTableView DataKeyNames="ProductID" 
                                          GroupLoadMode="Client" 
                                          TableLayout="Fixed" 
                                          CommandItemDisplay="top"
                                        <CommandItemSettings  
                                                ShowExportToCsvButton="true"  
                                                ShowExportToExcelButton="true"  
                                                ShowExportToWordButton="true" /> 
                            <Columns> 
                                <telerik:GridBoundColumn HeaderText="ProductID" DataField="ProductID" Visible="false"></telerik:GridBoundColumn> 
                                <telerik:GridTemplateColumn HeaderText="SKU" DataField="ShortSKU" Groupable="true" GroupByExpression="Group By ShortSKU" SortExpression="ShortSKU" ItemStyle-Width="80px" HeaderStyle-Width="80px" UniqueName="ShortSKUTemplate"
                                    <ItemTemplate> 
                                        <asp:Label runat="server" ID="lblShortSKU" Text='<%# Bind("ShortSKU") %>'></asp:Label> 
                                    </ItemTemplate> 
                                    <FooterTemplate> 
                                        <asp:Label runat="server" ID="lblShortSKUCount"></asp:Label> 
                                    </FooterTemplate> 
                                </telerik:GridTemplateColumn> 
                                <telerik:GridBoundColumn HeaderText="Product" DataField="ProductDescription"></telerik:GridBoundColumn> 
                                <telerik:GridBoundColumn HeaderText="Category" DataField="WebCatName" ItemStyle-Width="150px" HeaderStyle-Width="150px"></telerik:GridBoundColumn> 
                                <telerik:GridBoundColumn HeaderText="Property" DataField="FeaturePropertyName" ItemStyle-Width="150px" HeaderStyle-Width="150px"></telerik:GridBoundColumn> 
                                <telerik:GridBoundColumn HeaderText="Group" DataField="PropertyGroupName" ItemStyle-Width="200px" HeaderStyle-Width="200px"></telerik:GridBoundColumn> 
                                <telerik:GridBoundColumn HeaderText="CG" DataField="CoordinateGroup" ItemStyle-Width="50px" HeaderStyle-Width="50px"></telerik:GridBoundColumn> 
                                <telerik:GridBoundColumn HeaderText="DK" DataField="Deck" ItemStyle-Width="25px" HeaderStyle-Width="25px"></telerik:GridBoundColumn> 
                                <telerik:GridBoundColumn HeaderText="OH" DataField="RetailChainOnHand" ItemStyle-Width="30px" HeaderStyle-Width="30px"></telerik:GridBoundColumn> 
                                <telerik:GridBoundColumn HeaderText="Type" DataField="EndecaType" ItemStyle-Width="50px" HeaderStyle-Width="50px"></telerik:GridBoundColumn> 
                                <telerik:GridBoundColumn HeaderText="Status" DataField="ProductStatus" ItemStyle-Width="60px" HeaderStyle-Width="60px"></telerik:GridBoundColumn> 
                            </Columns> 
                             
                         </MasterTableView> 
                         <ClientSettings AllowGroupExpandCollapse="True"  
                                         ReorderColumnsOnClient="True"  
                                         AllowDragToGroup="True" 
                                         AllowColumnsReorder="True"
                            <Selecting AllowRowSelect="True" /> 
                        </ClientSettings> 
                        <GroupingSettings ShowUnGroupButton="true" /> 
        </telerik:RadGrid> 

0
Pavlina
Telerik team
answered on 20 Nov 2009, 04:19 PM
Hi TAD,

I followed your scenario in order to replicate the issue but to no avail. Please find attached a simple working project which is working as expected. Give it a try and let me know if you need further assistance.

Additionally, please review the following help article for more information about GroupByExpression property for a GridTemplateColumn.
http://www.telerik.com/help/aspnet-ajax/grdgroupbydeclarativedefinition.html (Template column section)

I hope this helps.

Regards,
Pavlina
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Teng Mua
Top achievements
Rank 1
answered on 27 Jul 2011, 11:27 PM
I'm having a simular issue with group by expresssion.  The links you provided can not be displayed so I can't see the examples.  I need more instructions on how to fix the issue.  This is the error I'm receiving on postback: "An error occured adding a relation to DataRelationCollection. Please, make sure you have configured the expressions properly - both GroupByFields and SelectFields are required" . 
0
Pavlina
Telerik team
answered on 28 Jul 2011, 08:52 AM
Hello Teng Mua,

You can find the correct link here:
http://www.telerik.com/help/aspnet-ajax/grid-group-by-declarative-definition.html

All the best,
Pavlina
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

0
Teng Mua
Top achievements
Rank 1
answered on 01 Aug 2011, 07:11 PM
I still can't figure out how to resolve the issue presented above.  The initial run is OK, but any postback and rebind gives an error.  Here is how I group by.

 

 

Dim DA As Data.SqlClient.SqlDataAdapter

 

 

Dim DS As New Data.DataSet

 

 

Dim SQL As String

 

myConnection.ConnectionString = strCon

myConnection.Open()

SQL =

"SELECT a.JOURNAL_ID,D.PROJECT_ID,D.PROJECT_NAME, b.COMPONENT, c.TASK_TYPE, a.JOURNAL, a.ENTRY_BY, convert(varchar(10),a.JOURNAL_DATE,101) AS DATE, a.HOUR FROM JOURNAL_TBL AS a LEFT OUTER JOIN COMPONENTS_TBL AS b ON a.COMP_ID = b.COMP_ID LEFT OUTER JOIN TASK_TYPE_TBL AS c ON a.TASK_ID = c.TASK_ID LEFT OUTER JOIN PROJECT_TBL AS D ON D.PROJECT_ID = A.PROJECT_ID WHERE a.ENTRY_BY = '" & Session("IntraID") & "' and a.JOURNAL_DATE BETWEEN '" & Session("BeginDate") & "' AND '" & Session("EndDates") & "'"

 

DA =

New Data.SqlClient.SqlDataAdapter(SQL, myConnection)

 

DA.Fill(DS,

"Recordset")

 

myConnection.Close()

RadGrid1.DataSource = DS

 

 

RadGrid1.DataBind()

RadGrid1.MasterTableView.GroupByExpressions.Add(

"Group by DATE")

 

RadGrid1.Rebind()

ERROR WITH POSTBACK.
An error occured adding a relation to DataRelationCollection. Please, make sure you have configured the expressions properly - both GroupByFields and SelectFields are required!

PLEASE HELP.  Thanks

0
Pavlina
Telerik team
answered on 04 Aug 2011, 12:30 PM
Hi Teng Mua,

The steps to build GroupByExpressions programmatically for the RadGrid is demonstrated in this online example:
http://demos.telerik.com/aspnet-ajax/grid/examples/groupby/expressions/defaultcs.aspx

Make sure that you specify at least one selectfield and one groupbyfield for the dynamically created expression so that grouping functions properly.

Kind regards,
Pavlina
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

Tags
Grid
Asked by
Jes
Top achievements
Rank 1
Answers by
Pavlina
Telerik team
Jes
Top achievements
Rank 1
TAD RHODES
Top achievements
Rank 1
Teng Mua
Top achievements
Rank 1
Share this question
or