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

Self referencing RadGrid's GridTemplateColumn displays values twice if it has both UniqueName attribute and ItemTemplate tag

3 Answers 79 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Sridhar
Top achievements
Rank 1
Sridhar asked on 21 Mar 2012, 04:55 AM
Hi,
I have a RadGrid which has NestedHierarchy set up. I also have edit functionality associated to grid rows.

<Columns>
    <telerik:GridEditCommandColumn ButtonType="ImageButton" UniqueName="EditCommandColumn" EditText="Rename Favourite" HeaderStyle-Width="15px">
        <ItemStyle CssClass="edit-grid-controls" />
    </telerik:GridEditCommandColumn>
    <telerik:GridTemplateColumn HeaderText="Name" UniqueName="Name">
        <ItemTemplate> 
<%# Eval("Name") %> </ItemTemplate>
        <EditItemTemplate><asp:TextBox ID="txtFavouriteName" runat="server" Text='<%# Eval("Name") %>' Width="100%" MaxLength="256" />
        </EditItemTemplate>
    </telerik:GridTemplateColumn>
    ... more columns ...
</Columns>

1. Since the time this grid was converted to a nested self referencing hierarchy table, the Name is displayed twice!
2. If I remove UniqueName attribute, the data wont show up.
3. If I remove ItemTemplate, things are fine until I attempt for an edit thru "GridEditCommandColumn".
4. Please have a look at the attached images. Image ending with right is for "normal" radgrid. Image ending with "wrong" is for nested hierarchy grid. When in edit mode, I don't want to display values twice.

3 Answers, 1 is accepted

Sort by
0
Andrey
Telerik team
answered on 26 Mar 2012, 08:00 AM
Hi,

In order to give you a resolution for the problem I will need more information about your setup, like the declaration of RadGrid along with the respective event handlers.

Regards,
Andrey
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Sridhar
Top achievements
Rank 1
answered on 05 Apr 2012, 01:03 AM
Hi,
Sorry for the delay. Here's my code.
"UniqueName" attribute is whats causing the trouble, but looks like that's inevitable.
<telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="false" AllowPaging="false" AllowMultiRowSelection="true"
                OnUpdateCommand="RadGrid1_UpdateCommand" OnItemDataBound="RadGrid1_ItemDataBound" OnDataBinding="RadGrid1_DataBinding"
                OnRowDrop="RadGrid1_RowDrop" OnNeedDataSource="RadGrid1_NeedDataSource" Visible="false"
                OnColumnCreated="RadGrid1_ColumnCreated" OnItemCreated="RadGrid1_ItemCreated" EnableLinqExpressions="false">
                <ClientSettings AllowRowsDragDrop="true" AllowDragToGroup="false" AllowExpandCollapse="true">
                    <Selecting AllowRowSelect="true" />
                    <ClientEvents OnRowDropping="onRowDropping" OnRowDragStarted="onRowDragStarted" OnRowContextMenu="RowContextMenu" />
                </ClientSettings>
                <MasterTableView ClientDataKeyNames="TrackingNumber" DataKeyNames="TrackingNumber, Name, OrderId, MasterOrderId, IsMaster" EditMode="InPlace"
                 HierarchyDefaultExpanded="false" HierarchyLoadMode="Client">
                    <SelfHierarchySettings ParentKeyName="MasterOrderId" KeyName="OrderId" MaximumDepth="1" />
                    <Columns>
                        <telerik:GridEditCommandColumn ButtonType="ImageButton" UniqueName="EditCommandColumn" EditText="Rename Order" HeaderStyle-Width="15px">
                            <ItemStyle CssClass="edit-grid-controls" />
                        </telerik:GridEditCommandColumn>
                        <telerik:GridTemplateColumn HeaderText="Name" UniqueName="Name">
                            <EditItemTemplate><asp:TextBox ID="txtOrderName" runat="server" Text='<%# Eval("Name") %>' Width="100%" MaxLength="256" /></EditItemTemplate>
                        </telerik:GridTemplateColumn>
                        <telerik:GridTemplateColumn HeaderText="Pax" HeaderStyle-Width="30px" HeaderStyle-HorizontalAlign="Right" ItemStyle-HorizontalAlign="Right">
                            <ItemTemplate><asp:Literal ID="litPax" runat="server" Text="-" /></ItemTemplate>
                        </telerik:GridTemplateColumn>
                        <telerik:GridTemplateColumn HeaderText="Provider Total" HeaderStyle-Width="100px" HeaderStyle-HorizontalAlign="Right" ItemStyle-HorizontalAlign="Right">
                            <ItemTemplate><asp:Literal ID="litLocalTotal" runat="server" Text="-" /></ItemTemplate>
                        </telerik:GridTemplateColumn>
                        <telerik:GridTemplateColumn HeaderText="Customer Total" HeaderStyle-Width="100px" HeaderStyle-HorizontalAlign="Right" ItemStyle-HorizontalAlign="Right">
                            <ItemTemplate><asp:Literal ID="litCustomerTotal" runat="server" Text="-" /></ItemTemplate>
                        </telerik:GridTemplateColumn>
                        <telerik:GridTemplateColumn HeaderText="Price Per Pax" HeaderStyle-Width="100px" HeaderStyle-HorizontalAlign="Right" ItemStyle-HorizontalAlign="Right">
                            <ItemTemplate><asp:Literal ID="litPricePerPax" runat="server" Text="-" /></ItemTemplate>
                        </telerik:GridTemplateColumn>
                        <telerik:GridTemplateColumn HeaderStyle-Width="62px" ItemStyle-HorizontalAlign="Left">
                            <ItemTemplate>
                                <asp:HyperLink ID="lnkEdit" Text="Edit" runat="server" NavigateUrl='<%# string.Format("{0}?{1}={2}&{3}={4}", PageConstants.OrderEdit, SiteConstants.BasketIdQueryStringKey, Eval("OrderId"), SiteConstants.SoldToIdQueryStringKey, Eval("SoldToId")) %>' />
                                <asp:ImageButton ID="imgPrint" runat="server" ToolTip="Print" OnCommand="Order_Command" CommandName="Print" CommandArgument='<%#Eval("SoldToId") + "," + Eval("TrackingNumber")%>' ImageUrl="~/SiteImages/PRINT.gif" CausesValidation="false" />
                            </ItemTemplate>
                        </telerik:GridTemplateColumn>
                    </Columns>
                    <NoRecordsTemplate>
                        <div>There are no orders in this category.</div>
                    </NoRecordsTemplate>
                </MasterTableView>
        </telerik:RadGrid>


Let me know if you need more details.

Thanks
Reddy
0
Andrey
Telerik team
answered on 05 Apr 2012, 03:36 PM
Hello,

I am afraid that Editing feature is not supported when SelfHierarchy structure is used. For such cases we recommend to use RadTreeList which is specifically designed for self -related  data.

All the best,
Andrey
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Grid
Asked by
Sridhar
Top achievements
Rank 1
Answers by
Andrey
Telerik team
Sridhar
Top achievements
Rank 1
Share this question
or