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

small Window/Radgrid positioning problem

1 Answer 49 Views
Window
This is a migrated thread and some comments may be shown as answers.
RW
Top achievements
Rank 1
RW asked on 06 Aug 2010, 07:43 PM
I have a sinking feeling that I'm going to feel stupid after one of you helps me with this one...

I'm positioning a RadWindow via OffsetElementID. That's working exactly as I want it to (opening the window right beside where the link in the Radgrid is), but whenever I click the Details link the page scrolls back to the top (it's not  a page refresh), which often hides the window if it was further down the list. Anyway ideas on how to stop this?

<telerik:RadWindowManager ID="RadWindowManager1" runat="server">
            <Windows>
                <telerik:RadWindow  
                    id="RadWindow1"
                    offsetelementid="detailsLink" 
                    runat="server"
                    showcontentduringload="false"
                    width="600px"
                    height="600px"
                    title="" 
                    visiblestatusbar="false"
                    reloadonshow="True" 
                    behaviors="Close, Move" 
                    skin="WebBlue">
                </telerik:RadWindow>
            </Windows>
 </telerik:RadWindowManager
   
 <telerik:RadGrid ID="RadGrid1" runat="server" AllowPaging="True" AllowSorting="True"
        DataSourceID="SqlDataSource1" GridLines=None Skin="WebBlue" PageSize="50" Width=100
        AllowFilteringByColumn=true ShowGroupPanel="True" OnItemCreated="RadGrid1_ItemCreated">
        <HeaderContextMenu EnableTheming="True" Skin="WebBlue">
            <CollapseAnimation Duration="200" Type="OutQuint" />
        </HeaderContextMenu>
        <ClientSettings AllowColumnsReorder="True" ReorderColumnsOnClient="True" AllowDragToGroup="True">
            <Selecting AllowRowSelect="True" />
        </ClientSettings>
        <MasterTableView GroupLoadMode=Client AutoGenerateColumns="False" DataKeyNames="pkRequestID" AllowMultiColumnSorting="True" DataSourceID="SqlDataSource1">
            <Columns>
                <telerik:GridBoundColumn  DataField="pkRequestID" HeaderText="ID" SortExpression="pkRequestID"
                    UniqueName="pkRequestID" FilterControlWidth="20px">
                    <HeaderStyle Width="5%" />
                       
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn  DataField="strTitle" HeaderText="Title" SortExpression="strTitle"
                    UniqueName="strTitle">
                    <HeaderStyle Width="50%" />
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="fullName" HeaderText="Submitted By" SortExpression="fullName"
                    UniqueName="fullName">
                    <HeaderStyle Width="15%" />
                </telerik:GridBoundColumn>
                <telerik:GridDateTimeColumn DataField="dteDate" HeaderText="Added" SortExpression="dteDate"
                    UniqueName="dteDate" DataFormatString="{0:MM/d/yy}">
                    <HeaderStyle Width="10%" HorizontalAlign=Center    />
                    <ItemStyle HorizontalAlign=Center />
                </telerik:GridDateTimeColumn>
                  
                <telerik:GridBoundColumn DataField="strStatus" HeaderText="Status" SortExpression="strStatus"
                    UniqueName="strStatus">
                     <HeaderStyle Width="10%" HorizontalAlign=Center  />
                     <ItemStyle HorizontalAlign=Center />
                </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="votes" HeaderText="Votes" SortExpression="votes"
                    UniqueName="votes" FilterControlWidth="20px">
                     <HeaderStyle Width="5%" HorizontalAlign=Center  />
                     <ItemStyle HorizontalAlign=Center />
                </telerik:GridBoundColumn>
                  
                <telerik:GridBoundColumn DataField="comments" HeaderText="Comments" SortExpression="comments"
                    UniqueName="comments" FilterControlWidth="20px">
                     <HeaderStyle Width="5%" HorizontalAlign=Center  />
                     <ItemStyle HorizontalAlign=Center />
                </telerik:GridBoundColumn>
                  
                <telerik:GridTemplateColumn UniqueName="pkRequestID" AllowFiltering="False">
                     <ItemTemplate>
                         <asp:HyperLink ID="detailsLink" runat="server" Text="Details"></asp:HyperLink>
                     </ItemTemplate>
                     <HeaderStyle Width="5%" HorizontalAlign=Center  />
                </telerik:GridTemplateColumn>
            </Columns>
            <ExpandCollapseColumn>
                <HeaderStyle Width="20px" />
            </ExpandCollapseColumn>
            <RowIndicatorColumn>
                <HeaderStyle Width="20px" />
            </RowIndicatorColumn>
        </MasterTableView>
          
        <PagerStyle Mode=NextPrevNumericAndAdvanced Position="TopAndBottom" />
    </telerik:RadGrid>

Here's my codebehind:
Private Sub RadGrid1_Init(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles RadGrid1.Init
    Dim menu As GridFilterMenu = RadGrid1.FilterMenu
    Dim i As Integer = 0
    While i < menu.Items.Count
        If menu.Items(i).Text = "NoFilter" Or _
           menu.Items(i).Text = "Contains" Or _
           menu.Items(i).Text = "DoesNotContain" Or _
           menu.Items(i).Text = "StartsWith" Or _
           menu.Items(i).Text = "EndsWith" Or _
           menu.Items(i).Text = "EqualTo" Or _
           menu.Items(i).Text = "NotEqualTo" Or _
           menu.Items(i).Text = "GreaterThan" Or _
           menu.Items(i).Text = "LessThan" Then
            i = i + 1
        Else
            menu.Items.RemoveAt(i)
        End If
    End While
End Sub 'RadGrid1_Init
    
Protected Sub clrFilters_Click(ByVal sender As Object, ByVal e As EventArgs)
    For Each column As GridColumn In RadGrid1.MasterTableView.Columns
        column.CurrentFilterFunction = GridKnownFunction.NoFilter
        column.CurrentFilterValue = String.Empty
    Next
    RadGrid1.MasterTableView.FilterExpression = String.Empty
    RadGrid1.MasterTableView.Rebind()
End Sub
  
Protected Sub RadGrid1_ItemCreated(ByVal sender As Object, ByVal e As GridItemEventArgs)
    If TypeOf e.Item Is GridDataItem Then
        Dim detailsLink As HyperLink = DirectCast(e.Item.FindControl("detailsLink"), HyperLink)
        detailsLink.Attributes("href") = "#"
        detailsLink.Attributes("onclick") = [String].Format("return openDetailsWin('{0}');", e.Item.OwnerTableView.DataKeyValues(e.Item.ItemIndex)("pkRequestID"))
    End If
End Sub

1 Answer, 1 is accepted

Sort by
0
Georgi Tunev
Telerik team
answered on 09 Aug 2010, 12:40 PM
Hi RW,

Try setting the detailsLink hyperlink like this:

Protected Sub RadGrid1_ItemCreated(ByVal sender As Object, ByVal e As GridItemEventArgs)
    If TypeOf e.Item Is GridDataItem Then
        Dim detailsLink As HyperLink = DirectCast(e.Item.FindControl("detailsLink"), HyperLink)
        'detailsLink.Attributes("href") = "#"
        'detailsLink.Attributes("onclick") = [String].Format("return openDetailsWin('{0}');", e.Item.OwnerTableView.DataKeyValues(e.Item.ItemIndex)("pkRequestID"))
        detailsLink.Attributes("href") = "javascript:void(0);"
        detailsLink.Attributes("onclick") = [String].Format("openDetailsWin('{0}'); return false;", e.Item.OwnerTableView.DataKeyValues(e.Item.ItemIndex)("pkRequestID"))
    End If
End Sub

When href is set to #, the browser treats the link as an anchor and usually will automatically scroll the page to top while trying to find that anchor in the content. To avoid that, I would suggest to use javascipt:void(0); instead.


Greetings,
Georgi Tunev
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
Window
Asked by
RW
Top achievements
Rank 1
Answers by
Georgi Tunev
Telerik team
Share this question
or