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

RadGrid popups up wrong RadWindow data.

5 Answers 88 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Shehab
Top achievements
Rank 1
Shehab asked on 28 Nov 2008, 03:30 PM

Hello All,

I am working on a RadGrid to pull data from the database, then added a select button to popup a RadWindow to show more details of that file, it works OK. But when I filter the grid, then click on the select button it will display the wrong data for a different row like it wasn't filtered here is the aspx:

<rad:radwindowmanager id="RadWindowManager1" runat="server" MinimizeZoneId="HorizontalMinimize" DestroyOnClose="True" Behavior="Maximize, Close, resize" Left="" NavigateUrl="" SkinsPath="~/RadControls/Window/Skins" Title="" Top="" Modal="True" Width="600px" Height="400px">  
        <Windows> 
            <rad:RadWindow ID="RadWindow1" runat="server" Left="" NavigateUrl="RadPhys.aspx" SkinsPath="~/RadControls/Window/Skins" 
            Title="Physician Information" Top="" /> 
        </Windows> 
    </rad:radwindowmanager> 
<radg:radgrid id="rgPhysician" runat="server" AutoGenerateColumns="False" GridLines="None" 
AllowFilteringByColumn="true" Skin="WebBlue" > 
    <MasterTableView DataKeyNames="PhysID">  
            <Columns> 
              <radG:GridTemplateColumn UniqueName="TemplateColumn">  
                <ItemTemplate> 
                    <asp:LinkButton ID="btnViewPhysician" runat="server" CommandName="Select" Text="Select">Select</asp:LinkButton> 
                </ItemTemplate> 
              </radG:GridTemplateColumn> 
              <radG:GridBoundColumn DataField="PhysID" Display="False" HeaderText="PhysID" 
                    ReadOnly="True" UniqueName="PhysID">  
              </radG:GridBoundColumn> 
              <radG:GridBoundColumn DataField="ContactType" Display="False" HeaderText="ContactType" 
                    ReadOnly="True" UniqueName="ContactType">  
              </radG:GridBoundColumn>              
              <radG:GridBoundColumn DataField="PhysFullName" HeaderText="Name" UniqueName="PhysFullName">  
              </radG:GridBoundColumn> 
              <radG:GridBoundColumn DataField="PhysSpeciality" HeaderText="Speciality" UniqueName="PhysSpeciality">  
              </radG:GridBoundColumn> 
              <radG:GridBoundColumn DataField="Office" HeaderText="Office" UniqueName="Office">  
              </radG:GridBoundColumn> 
            </Columns> 
        <RowIndicatorColumn Visible="False">  
            <HeaderStyle Width="20px" /> 
        </RowIndicatorColumn> 
        <ExpandCollapseColumn Visible="False">  
            <HeaderStyle Width="19px" /> 
        </ExpandCollapseColumn> 
    </MasterTableView> 
</radg:radgrid><br /> 
    <radA:RadAjaxManager ID="RadAjaxManager1" runat="server" EnablePageHeadUpdate="False">  
                <AjaxSettings> 
                    <radA:AjaxSetting AjaxControlID="RadWindowManager1">  
                        <UpdatedControls> 
                            <radA:AjaxUpdatedControl ControlID="RadWindowManager1" /> 
                        </UpdatedControls> 
                    </radA:AjaxSetting> 
                </AjaxSettings> 
</radA:RadAjaxManager> 

Here is the VB.NET

Imports Telerik.Web.UI  
Imports System.Collections  
Imports System.Data.SqlClient  
Imports System.Web.UI  
Imports System.Web.UI.WebControls  
Imports System.Web.UI.WebControls.WebParts  
Imports System.Web.UI.HtmlControls  
Imports System.Security.Principal  
Imports AjaxControlToolkit  
 
Partial Class PhysList  
    Inherits System.Web.UI.UserControl  
    Public dataConn As New PhoneBookDLL.dl  
 
    Protected Sub rgPhysician_Init(ByVal sender As ObjectByVal e As System.EventArgs) Handles rgPhysician.Init  
        Dim menu As GridFilterMenu = rgPhysician.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 = "EqualTo" Or menu.Items(i).Text = "StartsWith" Or _  
         menu.Items(i).Text = "EndsWith" Then 
                i = i + 1  
            Else 
                menu.Items.RemoveAt(i)  
            End If 
        End While 
    End Sub 
 
    Protected Sub rgPhysician_NeedDataSource(ByVal source As ObjectByVal e As Telerik.WebControls.GridNeedDataSourceEventArgs) Handles rgPhysician.NeedDataSource  
        Dim getDS As New DataSet  
        getDS = dataConn.PhoneActivePhys()  
        rgPhysician.DataSource = getDS.Tables(0).DefaultView  
    End Sub 
 
    Public Sub ViewPhysicianInfo(ByVal sender As ObjectByVal e As System.EventArgs) Handles rgPhysician.SelectedIndexChanged  
        Dim x As String = rgPhysician.MasterTableView.Items(rgPhysician.SelectedIndexes(0)).Item("PhysID").Text  
        Dim PhysID As String = rgPhysician.SelectedValue.ToString  
        'Dim PhysID As String = rgPhysician.SelectedIndexes.Item(0).ToString  
        'Dim PhysID As String = rgPhysician.SelectedItems.Item("PhysID").ToString  
        RadWindowManager1.VisibleOnPageLoad = True 
        RadWindow1.NavigateUrl = "RadPhys.aspx?ID=" & PhysID  
    End Sub 
 
    'Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load  
    '    If Not IsPostBack Then  
    '        Dim getDS As New DataSet  
    '        getDS = dataConn.PhoneActivePhys()  
    '        rgPhysician.DataSource = getDS.Tables(0).DefaultView  
    '        rgPhysician.DataBind()  
    '    End If  
    'End Sub  
End Class 

Thanks for all your help,
Sheheb

5 Answers, 1 is accepted

Sort by
0
Iana Tsolova
Telerik team
answered on 01 Dec 2008, 11:20 AM
Hi Shehab,

Please try resetting the VisibleOnPageLoad property of the window manager to false on page load as shown below and let me know if this helps:

Protected Sub Page_Load(ByVal sender As ObjectByVal e As EventArgs) handles Me.Load  
    RadWindowManager1.VisibleOnPageLoad = False 
End Sub 

Greetings,
Iana
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Shehab
Top achievements
Rank 1
answered on 01 Dec 2008, 01:29 PM
Thank you for your reply, I did try that on the page load but it didn't fix it. I am gonna try to explain the problem in a better way; when I bind the grid and then select a row to pop up the record deatails, it works fine as it gets the row count not the PhysID as I wish it would do, then it pulls the information fine. When I filter the RadGrid and then select a record, it get the row count again and then get the information for that count, not as I filtered. Make sense?
0
Iana Tsolova
Telerik team
answered on 01 Dec 2008, 02:22 PM
Hi Shehab,

Could you please try the attached sample and let me know how it works on your end and if I missed something from your logic?

Regards,
Iana
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Shehab
Top achievements
Rank 1
answered on 10 Dec 2008, 08:34 PM
Hello,

Thank you for your reply, your example works fine but still not the same as my situation. Please take a look at this code:
<%@ Control Language="VB" AutoEventWireup="false" CodeFile="PersonList.ascx.vb" Inherits="PersonList" %> 
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %> 
 
<script type="text/javascript">  
   function centerUpdatePanel()  
   {  
    centerElementOnScreen(document.getElementById("LoadingPanel1"));  
   }  
   function centerElementOnScreen(element)  
   {  
    var scrollTop = document.body.scrollTop;  
    var scrollLeft = document.body.scrollLeft;  
    var viewPortHeight = document.body.clientHeight;  
    var viewPortWidth = document.body.clientWidth;  
    if (document.compatMode == "CSS1Compat")  
    {  
     viewPortHeight = document.documentElement.clientHeight;  
     viewPortWidth = document.documentElement.clientWidth;  
     scrollTop = document.documentElement.scrollTop;  
     scrollLeft = document.documentElement.scrollLeft;  
    }  
    var topOffset = Math.ceil(viewPortHeight/2 - element.offsetHeight/2);  
    var leftOffset = Math.ceil(viewPortWidth/2 - element.offsetWidth/2);  
    var top = scrollTop + topOffset - 40;  
    var left = scrollLeft + leftOffset - 70;  
       element.style.position = "absolute";  
    element.style.top = top + "px";  
    element.style.left = left + "px";  
}  
</script> 
 
<asp:Button ID="btnPrint" runat="server" Text="Create PDF for printing" CausesValidation="False" /> 
<telerik:radwindowmanager id="RadWindowManager1" runat="server" MinimizeZoneId="HorizontalMinimize" DestroyOnClose="True" Behavior="Maximize, Close, resize" Left="" NavigateUrl="" SkinsPath="~/RadControls/Window/Skins" Title="" Top="" Modal="True" Width="600px" Height="400px">  
        <Windows> 
            <telerik:RadWindow ID="RadWindow1" runat="server" Left="" NavigateUrl="RadPerson.aspx" SkinsPath="~/RadControls/Window/Skins" 
            Title="Physician Information" Top="" /> 
        </Windows> 
</telerik:radwindowmanager> 
<telerik:RadGrid ID="dgPerson" runat="server" 
    AutoGenerateColumns="False" GridLines="None" Skin="WebBlue" AllowSorting="True" > 
    <MasterTableView DataKeyNames="PersonID">  
            <Columns>    
              <telerik:GridTemplateColumn UniqueName="TemplateColumn">  
                <ItemTemplate> 
                    <asp:LinkButton ID="btnViewPerson" runat="server" CommandName="Select" Text="Select">Select</asp:LinkButton> 
                </ItemTemplate> 
              </telerik:GridTemplateColumn>              
              <telerik:GridBoundColumn DataField="PersonID" Display="False" HeaderText="PersonID" 
                    ReadOnly="True" UniqueName="PersonID">  
              </telerik:GridBoundColumn> 
              <telerik:GridBoundColumn DataField="ContactType" Display="False" HeaderText="ContactType" 
                    ReadOnly="True" UniqueName="ContactType">  
              </telerik:GridBoundColumn>              
              <telerik:GridBoundColumn DataField="LastName" HeaderText="Last Name" UniqueName="LastName">  
              </telerik:GridBoundColumn> 
              <telerik:GridBoundColumn DataField="FirstName" HeaderText="First Name" UniqueName="FirstName">  
              </telerik:GridBoundColumn>                
              <telerik:GridBoundColumn DataField="Ext" HeaderText="Ext" UniqueName="Ext">  
              </telerik:GridBoundColumn> 
              <telerik:GridBoundColumn DataField="DepName" HeaderText="Dep" UniqueName="DepName">  
              </telerik:GridBoundColumn> 
 
            </Columns> 
        <RowIndicatorColumn> 
            <HeaderStyle Width="20px" /> 
        </RowIndicatorColumn> 
        <ExpandCollapseColumn> 
            <HeaderStyle Width="20px" /> 
        </ExpandCollapseColumn> 
 
    </MasterTableView> 
    <HeaderContextMenu EnableTheming="True" Skin="WebBlue">  
        <CollapseAnimation Duration="200" Type="OutQuint" /> 
    </HeaderContextMenu> 
    <FilterMenu EnableTheming="True" Skin="WebBlue">  
        <CollapseAnimation Duration="200" Type="OutQuint" /> 
    </FilterMenu> 
</telerik:RadGrid> 
<telerik:RadAjaxManagerProxy ID="RadAjaxManagerProxy1" runat="server">  
    <AjaxSettings> 
        <telerik:AjaxSetting AjaxControlID="dgPerson">  
            <UpdatedControls> 
                <telerik:AjaxUpdatedControl ControlID="RadWindowManager1" LoadingPanelID="RadAjaxLoadingPanel1" /> 
                <telerik:AjaxUpdatedControl ControlID="dgPerson" LoadingPanelID="RadAjaxLoadingPanel1" /> 
            </UpdatedControls> 
        </telerik:AjaxSetting> 
    </AjaxSettings> 
</telerik:RadAjaxManagerProxy> 
Imports System.Data  
Imports Telerik.Web  
Imports Telerik.Web.UI  
Imports System.Collections  
Imports System.Data.SqlClient  
Imports System.Web.UI  
Imports System.Web.UI.WebControls  
Imports System.Web.UI.WebControls.WebParts  
Imports System.Web.UI.HtmlControls  
Imports System.Security.Principal  
Imports AjaxControlToolkit  
Partial Class PersonList  
    Inherits System.Web.UI.UserControl  
    Public dataConn As New PhoneBookDLL.dl  
 
    Protected Sub dgPerson_NeedDataSource(ByVal source As ObjectByVal e As Telerik.Web.UI.GridNeedDataSourceEventArgs) Handles dgPerson.NeedDataSource  
        Dim getDS As New DataSet  
        getDS = dataConn.PhoneActivePerson()  
        dgPerson.DataSource = getDS.Tables(0).DefaultView  
    End Sub 
 
    Protected Sub Page_Load(ByVal sender As ObjectByVal e As System.EventArgs) Handles Me.Load  
        RadWindowManager1.VisibleOnPageLoad = False 
        Page.Title = "Phonebook Personnel Directory" 
        Dim url As String = "RptPersonnel.aspx" 
        btnPrint.Attributes.Add("OnClick""window.open('" & url & "', title, 'top=0,left=0,height=570,width=787,scrollbars=yes,resizable=yes')")  
    End Sub 
 
    Public Sub ViewPhysicianInfo(ByVal sender As ObjectByVal e As System.EventArgs) Handles dgPerson.SelectedIndexChanged  
        Dim x As String = dgPerson.MasterTableView.Items(dgPerson.SelectedIndexes(0)).Item("PersonID").Text  
        Dim PersonID As String = dgPerson.SelectedValue.ToString  
        RadWindowManager1.VisibleOnPageLoad = True 
        RadWindow1.NavigateUrl = "RadPerson.aspx?ID=" & PersonID  
    End Sub 
End Class 

I think it is because I have the NeedDataSource, whenever I click on the sorting, it sorts fine then when I select a column to display its details information, it goes to the NeedDataSource first, gets the data from the database and then it selects the record... Thank you again for all your help and patience.

Thanks,
Shehab
0
Iana Tsolova
Telerik team
answered on 12 Dec 2008, 01:35 PM
Hello Shehab,

I modified the sample following the further information provided. Please check it out and let me know what differs in you case.

Greetings,
Iana
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Grid
Asked by
Shehab
Top achievements
Rank 1
Answers by
Iana Tsolova
Telerik team
Shehab
Top achievements
Rank 1
Share this question
or