Problem with display name of foreignkey when groupby

4 posts, 0 answers
  1. Trung Lee
    Trung Lee avatar
    5 posts
    Member since:
    Apr 2010

    Posted 22 Feb 2013 Link to this post

    As attach Image, please help me to display name replace Id when group by foreign key. thanks
  2. Jayesh Goyani
    Jayesh Goyani avatar
    2732 posts
    Member since:
    May 2010

    Posted 22 Feb 2013 Link to this post

    Hello,

    I am not able to reproduce this issue.

    Please check below code and screenshot.

    <telerik:RadGrid ID="RadGrid1" runat="server" DataSourceID="SqlDataSource1">
                <MasterTableView AutoGenerateColumns="False" DataKeyNames="StudentID" DataSourceID="SqlDataSource1">
                    <GroupByExpressions>
                        <telerik:GridGroupByExpression>
                            <SelectFields>
                                <telerik:GridGroupByField FieldAlias="AcademyName" FieldName="AcademyName"></telerik:GridGroupByField>
                            </SelectFields>
                            <GroupByFields>
                                <telerik:GridGroupByField FieldName="AcademyName" SortOrder="Ascending"></telerik:GridGroupByField>
                            </GroupByFields>
                        </telerik:GridGroupByExpression>
                    </GroupByExpressions>
                    <CommandItemSettings ExportToPdfText="Export to PDF"></CommandItemSettings>
                    <RowIndicatorColumn Visible="True" FilterControlAltText="Filter RowIndicator column">
                        <HeaderStyle Width="20px"></HeaderStyle>
                    </RowIndicatorColumn>
                    <ExpandCollapseColumn Visible="True" FilterControlAltText="Filter ExpandColumn column">
                        <HeaderStyle Width="20px"></HeaderStyle>
                    </ExpandCollapseColumn>
                    <Columns>
                        <telerik:GridBoundColumn DataField="StudentID" DataType="System.Int32" FilterControlAltText="Filter StudentID column"
                            HeaderText="StudentID" ReadOnly="True" SortExpression="StudentID" UniqueName="StudentID">
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="StudentName" FilterControlAltText="Filter StudentName column"
                            HeaderText="StudentName" SortExpression="StudentName" UniqueName="StudentName">
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="AcademyName" FilterControlAltText="Filter AcademyName column"
                            HeaderText="AcademyName" SortExpression="AcademyName" UniqueName="AcademyName">
                        </telerik:GridBoundColumn>
                    </Columns>
                    <EditFormSettings>
                        <EditColumn FilterControlAltText="Filter EditCommandColumn column">
                        </EditColumn>
                    </EditFormSettings>
                </MasterTableView>
                <FilterMenu EnableImageSprites="False">
                </FilterMenu>
            </telerik:RadGrid>
            <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:JayeshTestConnectionString %>"
                SelectCommand="SELECT StudentDetails.StudentID, StudentDetails.StudentName, AcademyDetail.AcademyName, AcademyDetail.AcademyID FROM StudentDetails INNER JOIN AcademyDetail ON AcademyDetail.StudentID = StudentDetails.StudentID">
            </asp:SqlDataSource>







    Note : Please try with below code snippet. if you are not able to resolved this issue then please elaborate your scenario or provide your code.

    Thanks,
    Jayesh Goyani
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Trung Lee
    Trung Lee avatar
    5 posts
    Member since:
    Apr 2010

    Posted 22 Feb 2013 Link to this post

    Thanks for your fast reply.
    -As same as your example, but i want to group by StudentName and display StudentName on that Groupby, how to do that? Because Student as a foreign key of Academy, and it will display StudentID instead of StudentName.

    Thanks Jayesh Goyani very much!
  5. Jayesh Goyani
    Jayesh Goyani avatar
    2732 posts
    Member since:
    May 2010

    Posted 24 Feb 2013 Link to this post

    Hello,



    <MasterTableView AutoGenerateColumns="False" DataKeyNames="StudentID" DataSourceID="SqlDataSource1">
                   <GroupByExpressions>
                       <telerik:GridGroupByExpression>
                           <SelectFields>
                               <telerik:GridGroupByField FieldAlias="StudentName" FieldName="StudentName"></telerik:GridGroupByField>
                           </SelectFields>
                           <GroupByFields>
                               <telerik:GridGroupByField FieldName="StudentName" SortOrder="Ascending"></telerik:GridGroupByField>
                           </GroupByFields>
                       </telerik:GridGroupByExpression>
                   </GroupByExpressions>
                   <CommandItemSettings ExportToPdfText="Export to PDF"></CommandItemSettings>
                   <RowIndicatorColumn Visible="True" FilterControlAltText="Filter RowIndicator column">
                       <HeaderStyle Width="20px"></HeaderStyle>
                   </RowIndicatorColumn>
                   <ExpandCollapseColumn Visible="True" FilterControlAltText="Filter ExpandColumn column">
                       <HeaderStyle Width="20px"></HeaderStyle>
                   </ExpandCollapseColumn>
                   <Columns>
                       <telerik:GridBoundColumn DataField="StudentName" FilterControlAltText="Filter StudentName column"
                           HeaderText="StudentName" SortExpression="StudentName" UniqueName="StudentName">
                       </telerik:GridBoundColumn>
                       <telerik:GridBoundColumn DataField="AcademyName" FilterControlAltText="Filter AcademyName column"
                           HeaderText="AcademyName" SortExpression="AcademyName" UniqueName="AcademyName">
                       </telerik:GridBoundColumn>
                       <telerik:GridBoundColumn DataField="AcademyID" DataType="System.Int32" FilterControlAltText="Filter AcademyID column"
                           HeaderText="AcademyID" ReadOnly="True" SortExpression="AcademyID" UniqueName="AcademyID">
                       </telerik:GridBoundColumn>
                   </Columns>
                   <EditFormSettings>
                       <EditColumn FilterControlAltText="Filter EditCommandColumn column">
                       </EditColumn>
                   </EditFormSettings>
               </MasterTableView>

    Sorry but still i am not able to reproduce this issue. (DLL version : 2012.3.1016.40)

    If possible than can you please provide your code.

    Thanks,
    Jayesh Goyani
Back to Top