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

GridFilteringItem cells offset by two? Tooltips are skewed

4 Answers 56 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jerry T.
Top achievements
Rank 1
Jerry T. asked on 24 Sep 2010, 09:12 PM

First, I'm using the most recent version of the RadAJAX controls.

I've been trying to set, in the codebehind, the filter control tooltip to the text equivalent of the CurrentFilterFunction that's defined in the markup.  I finally came up with a solution but my tooltips were shifted by two columns.  It's like there are two "hidden" GridFilterItem cells in that row in the grid.

Here is the markup:

 

 

 

 


<telerik:RadGrid ID="radgrdMyPrograms" runat="server" Width="100%"  DataSourceID="ldsProgramsAllByUserName" EnableLinqExpressions="false"
    EnableEmbeddedSkins="false" Skin="DMCpro" ShowStatusBar="true"
    AutoGenerateColumns="false" AllowFilteringByColumn="true" AllowPaging="true" AllowSorting="true" PageSize="20" >
    <ClientSettings EnableRowHoverStyle="true" Selecting-AllowRowSelect="true" Scrolling-AllowScroll="true" Scrolling-ScrollHeight="600px" Scrolling-UseStaticHeaders="true" />
    <MasterTableView TableLayout="Fixed" DataKeyNames="ProgramID,ProgramName,ClientId,Client" >
        <HeaderStyle Font-Size="Small" Font-Bold="true" />
        <ItemStyle Font-Size="Small" Wrap="false" />
        <AlternatingItemStyle Font-Size="Small" Wrap="false" />
        <Columns>
            <telerik:GridHyperLinkColumn HeaderText="Program #" DataTextField="ProgramID" SortExpression="ProgramID" UniqueName="ProgramID"
                HeaderStyle-Width="80px" HeaderStyle-HorizontalAlign="Left"
                AllowFiltering="false" />
            <telerik:GridBoundColumn HeaderText="Program" DataField="ProgramName" SortExpression="ProgramName"
                HeaderStyle-Width="150px" HeaderStyle-HorizontalAlign="Left"
                CurrentFilterFunction="Contains" AutoPostBackOnFilter="true" ShowFilterIcon="false" FilterControlWidth="150px" />
            <telerik:GridBoundColumn HeaderText="AE" DataField="AEName" SortExpression="AEName"
                HeaderStyle-Width="35px" HeaderStyle-HorizontalAlign="Left"
                AllowFiltering="false" />
            <telerik:GridBoundColumn HeaderText="Start&nbsp;Date" DataField="StartDate" SortExpression="StartDate" 
                HeaderStyle-Width="65px" HeaderStyle-HorizontalAlign="Left" DataFormatString="{0:MM/dd/yyyy}" DataType="System.DateTime"
                CurrentFilterFunction="GreaterThanOrEqualTo" AutoPostBackOnFilter="true" ShowFilterIcon="false" FilterControlWidth="60px" />
            <telerik:GridBoundColumn HeaderText="End Date" DataField="EndDate" SortExpression="EndDate"
                HeaderStyle-Width="65px" HeaderStyle-HorizontalAlign="Left" DataFormatString="{0:MM/dd/yyyy}" DataType="System.DateTime"
                CurrentFilterFunction="LessThanOrEqualTo" AutoPostBackOnFilter="true" ShowFilterIcon="false" FilterControlWidth="60px" />
            <telerik:GridBoundColumn HeaderText="Status" DataField="Status" SortExpression="Status"
                HeaderStyle-Width="92px" HeaderStyle-HorizontalAlign="Left"
                CurrentFilterFunction="EqualTo" AutoPostBackOnFilter="true" ShowFilterIcon="false" FilterControlWidth="90px" />
            <telerik:GridBoundColumn HeaderText="Revenue" DataField="Revenue" SortExpression="Revenue"
                HeaderStyle-Width="100px" HeaderStyle-HorizontalAlign="Left" DataFormatString="{0:C}" ItemStyle-HorizontalAlign="Right"
                CurrentFilterFunction="EqualTo" AutoPostBackOnFilter="true" ShowFilterIcon="false" />
            <telerik:GridHyperLinkColumn HeaderText="Client" DataTextField="Client" SortExpression="Client" UniqueName="Client"
                HeaderStyle-Width="170px"
                CurrentFilterFunction="Contains" AutoPostBackOnFilter="true" ShowFilterIcon="false" FilterControlWidth="170px" />
            <telerik:GridBoundColumn HeaderText="Market" DataField="Market" SortExpression="Market"
                HeaderStyle-Width="90px" HeaderStyle-HorizontalAlign="Left"
                CurrentFilterFunction="EqualTo" AutoPostBackOnFilter="true" ShowFilterIcon="false" />
            <telerik:GridBoundColumn HeaderText="Bus. Source" DataField="BusinessSource" SortExpression="BusinessSource"
                HeaderStyle-Width="100px" HeaderStyle-HorizontalAlign="Left"
                CurrentFilterFunction="EqualTo" AutoPostBackOnFilter="true" ShowFilterIcon="false" />
            <telerik:GridBoundColumn HeaderText="Pax" DataField="Guests" SortExpression="Guests"
                HeaderStyle-Width="45px" HeaderStyle-HorizontalAlign="Left" ItemStyle-HorizontalAlign="Right"
                CurrentFilterFunction="EqualTo" AutoPostBackOnFilter="true" AllowFiltering="false" />
        </Columns>
    </MasterTableView>
</telerik:RadGrid>


And here is the codebehind:

 

 

 

 

 

 

    Private Sub radgrdMyPrograms_ItemDataBound(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridItemEventArgs) Handles radgrdMyPrograms.ItemDataBound
        If (TypeOf e.Item Is GridDataItem) Then
            Dim gdi As GridDataItem = DirectCast(e.Item, GridDataItem)

            Dim hlc As HyperLink = DirectCast(gdi.Item("ProgramID").Controls(0), HyperLink)
            hlc.NavigateUrl = "~/Programs/Programs.aspx?PNO=" + radgrdMyPrograms.MasterTableView.DataKeyValues(e.Item.ItemIndex)("ProgramID").ToString + "&PName=" + Replace(Server.UrlEncode(radgrdMyPrograms.MasterTableView.DataKeyValues(e.Item.ItemIndex)("ProgramName")), "'", "")
            hlc.CssClass = "info"

            Dim hlc2 As HyperLink = DirectCast(gdi.Item("Client").Controls(0), HyperLink)
            hlc2.NavigateUrl = "~/Crm/Clients.aspx?ClientId=" + radgrdMyPrograms.MasterTableView.DataKeyValues(e.Item.ItemIndex)("ClientId").ToString + "&ClientName=" + Replace(Server.UrlEncode(radgrdMyPrograms.MasterTableView.DataKeyValues(e.Item.ItemIndex)("Client")), "'", "")
            hlc2.CssClass = "info"
        ElseIf (TypeOf e.Item Is GridFilteringItem) Then
            Dim fi As GridFilteringItem = DirectCast(e.Item, GridFilteringItem)

            For i = 0 To radgrdMyPrograms.Columns.Count - 1
                fi.Cells(i + 2).ToolTip = radgrdMyPrograms.Columns(i).CurrentFilterFunction.ToString
            Next
        End If
    End Sub

 

 

 

 



Why do I have to have the (i + 2) in that last statement??

Jerry

 

4 Answers, 1 is accepted

Sort by
0
Jerry T.
Top achievements
Rank 1
answered on 24 Sep 2010, 09:28 PM
    
0
Jerry T.
Top achievements
Rank 1
answered on 28 Sep 2010, 04:24 PM
Any thoughts?

I'm having to do this consistently on every page that has a RadGrid.
0
Accepted
Princy
Top achievements
Rank 2
answered on 29 Sep 2010, 08:24 AM
Hello Jerry,

The column index starts at index 2 beacuse GridExpandColumn and GridRowindicatorColumn are always in front of data columns.

And the following code snippet shows how to set tooltip to filter item by using its ColumnUniqueName.

VB.Net:
Protected Sub RadGrid1_ItemDataBound(sender As Object, e As GridItemEventArgs)
    If TypeOf e.Item Is GridFilteringItem Then
        Dim filterItem As GridFilteringItem = DirectCast(e.Item, GridFilteringItem)
        Dim i As Integer = 0
        For Each col As GridColumn In RadGrid1.MasterTableView.Columns
            filterItem(col.UniqueName).ToolTip = RadGrid1.Columns(i).CurrentFilterFunction.ToString()
            i += 1
        Next
    End If
End Sub

Thanks,
Princy.
0
Jerry T.
Top achievements
Rank 1
answered on 29 Sep 2010, 01:30 PM
Thanks, Princy.

We're not using UniqueName but on a couple of columns but perhaps I might have to.  It's working fine I was just wondering if I was missing something and you answered that "something".

I will probably have to end up using your example for what I'm trying to accomplish here, too:

http://www.telerik.com/community/forums/aspnet-ajax/grid/is-there-a-way-to-persist-the-initial-currentfilterfunction.aspx
Tags
Grid
Asked by
Jerry T.
Top achievements
Rank 1
Answers by
Jerry T.
Top achievements
Rank 1
Princy
Top achievements
Rank 2
Share this question
or