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

HeaderContextMenu ignoring TemplateColumns

2 Answers 40 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Panther
Top achievements
Rank 1
Panther asked on 11 Aug 2010, 03:07 PM
I want to use the HeaderContextMenu for a RadGrid, but there are several TemplateColumns and they are being ignored by the HeaderContextMenu commands.

I am able to sort, group and filter by the normal BoundColumns, but if I try to do anything with one of the TemplateColumns it doesn't work. I added SortExpression and UniqueName to each of the templates, but still no dice.

Is there anything else I need to do to make it work?

Thanks

<telerik:RadGrid ID="rgLoads" runat="server" AutoGenerateColumns="false" AllowPaging="true" AllowSorting="true" AllowFilteringByColumn="true" OnItemCommand="rgLoads_ItemCommand" EnableHeaderContextMenu="true" EnableHeaderContextFilterMenu="true" OnItemDataBound="rgLoads_ItemDataBound" OnGroupsChanging="rgLoads_GroupsChanging" OnPageIndexChanged="rgLoads_PageIndexChanged">
        <HeaderContextMenu OnItemClick="HeaderContextMenu_ItemClick" />
        <GroupingSettings CaseSensitive="false" />        
        <MasterTableView IsFilterItemExpanded="false" EnableHeaderContextMenu="true" Width="100%">
            <Columns>
                <telerik:GridBoundColumn DataField="UrgHours" HeaderText="Urg Hrs" SortExpression="UrgHours" UniqueName="UrgHours" />
                <telerik:GridTemplateColumn HeaderText="LD Code" SortExpression="LoadCode" UniqueName="LoadCode">
                    <ItemTemplate>
                        <asp:HyperLink ID="LDCodeTarget" runat="server" NavigateUrl="#" Text='<%# Eval("LoadCode") %>' />
                    </ItemTemplate>
                </telerik:GridTemplateColumn>
                <telerik:GridBoundColumn DataField="SpotLight" HeaderText="Spotlight" SortExpression="SpotLight" UniqueName="SpotLight" />
                <telerik:GridTemplateColumn HeaderText="PRO" SortExpression="ProNo" UniqueName="ProNo">
                    <ItemTemplate>
                        <asp:HyperLink ID="ProTarget" runat="server" NavigateUrl="#" Text='<%# Eval("ProNo") %>' />
                    </ItemTemplate>
                </telerik:GridTemplateColumn>
                <telerik:GridBoundColumn DataField="LoadSegment" HeaderText="Load Seg" SortExpression="LoadSegment" UniqueName="LoadSegment" />
                <telerik:GridBoundColumn DataField="SendFromCity" HeaderText="Origin City" SortExpression="SendFromCity" UniqueName="SendFromCity" />
                <telerik:GridBoundColumn DataField="SendFromStateProv" HeaderText="Origin State" SortExpression="SendFromStateProv" UniqueName="SendFromStateProv" />
                <telerik:GridBoundColumn DataField="SendToCity" HeaderText="Dest City" SortExpression="SendToCity" UniqueName="SendToCity" />
                <telerik:GridBoundColumn DataField="SendToStateProv" HeaderText="Dest State" SortExpression="SendToStateProv" UniqueName="SendToStateProv" />
                <telerik:GridBoundColumn DataField="PickupDate" HeaderText="PU Dt" SortExpression="PickupDate" UniqueName="PickupDate" />
                <telerik:GridBoundColumn DataField="PickupTime" HeaderText="PU Tm" SortExpression="PickupTime" UniqueName="PickupTime" />                
                <telerik:GridBoundColumn DataField="LOH" HeaderText="LOH" SortExpression="LOH" UniqueName="LOH" />
                <telerik:GridBoundColumn DataField="MoveType" HeaderText="Move Type" SortExpression="MoveType" UniqueName="MoveType" />
                <telerik:GridBoundColumn DataField="STerm" HeaderText="STerm" SortExpression="STerm" UniqueName="STerm" />
                <telerik:GridBoundColumn DataField="DH" HeaderText="DH" SortExpression="DH" UniqueName="DH" />
                <telerik:GridTemplateColumn HeaderText="Assgn Code" SortExpression="AssignmentCode" UniqueName="AssignmentCode">
                    <ItemTemplate>
                        <asp:HyperLink ID="AssignmentCodeTarget" runat="server" NavigateUrl="#" Text='<%# Eval("AssignmentCode") %>' />
                    </ItemTemplate>
                </telerik:GridTemplateColumn>
                <telerik:GridTemplateColumn HeaderText="Error Code" SortExpression="ErrorCode" UniqueName="ErrorCode">
                    <ItemTemplate>
                        <asp:HyperLink ID="ErrorCodeTarget" runat="server" NavigateUrl="#" Text='<%# Eval("ErrorCode") %>' />
                    </ItemTemplate>
                </telerik:GridTemplateColumn>
                <telerik:GridTemplateColumn HeaderText="Recom" SortExpression="Recom" UniqueName="Recom">
                    <ItemTemplate>
                        <asp:Literal ID="litRecom" runat="server" Text='<%# Eval("Recom") %>' />
                        <asp:HyperLink ID="RecomTarget" runat="server" NavigateUrl="#" Text='<%# Eval("Recom") %>' />
                    </ItemTemplate>
                </telerik:GridTemplateColumn>
                <telerik:GridTemplateColumn HeaderText="Driver Code" SortExpression="DriverCode" UniqueName="DriverCode">
                    <ItemTemplate>
                        <asp:HyperLink ID="DriverCodeTarget" runat="server" NavigateUrl="#" Text='<%# Eval("DriverCode") %>' />
                    </ItemTemplate>
                </telerik:GridTemplateColumn>
                <telerik:GridBoundColumn DataField="MinsOfferSent" HeaderText="Mins Offer Sent" SortExpression="MinsOfferSent" UniqueName="MinsOfferSent" />
                <telerik:GridBoundColumn DataField="HTDaysOut" HeaderText="HT Days Out" SortExpression="HTDaysOut" UniqueName="HTDaysOut" />
                <telerik:GridBoundColumn DataField="TruckSize" HeaderText="Truck Size" SortExpression="TruckSize" UniqueName="TruckSize" />
                <telerik:GridBoundColumn DataField="DIV" HeaderText="DIV" SortExpression="DIV" UniqueName="DIV" />
            </Columns>
        </MasterTableView>
    </telerik:RadGrid>

2 Answers, 1 is accepted

Sort by
0
Panther
Top achievements
Rank 1
answered on 12 Aug 2010, 03:46 PM
I figured out how to do everything I need without using GridTemplateColumns and so the sorting, grouping and filtering works from the HeaderContextMenu. Now I am running into another issue...

In several columns I am using a RadToolTipManager to show additional information. I noticed that when I change pages on the grid I was still getting the tooltips from the first page. Another post explained that I need to clear the RadToolTipManager's TargetControls and that fixed the issue for PageIndexChanged, but I experience the same thing when I use the HeaderContextMenu.

What events are fired when I use the HeaderContextMenu to Sort? to Group? to Filter?
0
Daniel
Telerik team
answered on 17 Aug 2010, 03:00 PM
Hello Ryan,

I'm not sure how to reproduce the problem on my end. Could you please modify the attached project to demonstrate this behavior?

As to your question - you can intercept the HeaderContextMenu's ItemClick event as shown below:
protected void Page_Init(object sender, EventArgs e)
{
    RadGrid1.HeaderContextMenu.ItemClick += new RadMenuEventHandler(HeaderContextMenu_ItemClick);
}
 
void HeaderContextMenu_ItemClick(object sender, RadMenuEventArgs e)
{
    e.Item.Text...
}

Regards,
Daniel
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
Tags
Grid
Asked by
Panther
Top achievements
Rank 1
Answers by
Panther
Top achievements
Rank 1
Daniel
Telerik team
Share this question
or