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

RadWindow position

4 Answers 105 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Colince
Top achievements
Rank 1
Colince asked on 05 Jun 2013, 10:05 AM
Hi
i have many imageButton on my page and this imageButton are linked to the radwindow which is always open in the center position on my window. My problem is that i would like to open the radwindow next the imageButton that open it. So i wouldn't scroll the window to find the radwindow. 
below my script:

<telerik:GridTemplateColumn HeaderText="Dealers" HeaderStyle-Width="70px" AllowFiltering="false">
        <ItemTemplate>
                  <asp:ImageButton ID="Ib_Button" runat="server" CommandName="Redirect" ImageUrl='~/Images/Add.png' />
         </ItemTemplate
</telerik:GridTemplateColumn>


the command does this:

if (e.CommandName == "Redirect")        {             GridDataItem item = (GridDataItem)e.Item;             RadAjaxManager1.ResponseScripts.Add(string.Format("Open('{0}');", item.GetDataKeyValue("Code").ToString()));        }


and the javascript that open the radwindow is:
function Open(code) {
            var wnd = window.radopen('DealersD.aspx?Customer=' + code, "RadWindow1");
        }


Can someone help me to solve this problem .
Another question: how can i set the window so that is always view in the radwindow position?
Many thanks. 

4 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 07 Jun 2013, 05:15 AM
Hi,

Try the following code to position the Window.
JS:
function Open(code, index)
  {
       var radGrid = $find('<%= RadGrid1.ClientID %>'); // accessing the RadGrid
       var master = radGrid.get_masterTableView().get_dataItems()[index];
       var imgbutton = master.findElement("Img_Button"); // to get the button
       var location = $telerik.getLocation(imgbutton); // to get the location of the button in RadGrid
       var window = window.radopen(null, "RadWindow1");
       window.moveTo(location.x, location.y); //setting the window position
   }

Thanks,
Shinu.
0
Colince
Top achievements
Rank 1
answered on 07 Jun 2013, 10:19 AM
Hi Shinu!
First of all, thank you for your answer.
I need the parameter "index" to try your code . Could you kindly show me how to get the parameter "index" that the Open() function needs when the command "Redirect" is call.
Another issue is that <%= %> doesn't work and  i  need to change it with <%# %>.
0
Accepted
Shinu
Top achievements
Rank 2
answered on 07 Jun 2013, 10:43 AM
Hi,
Here is my full code.
ASPX:
<telerik:RadGrid runat="server" ID="RadGrid1" AutoGenerateColumns="false" AutoGenerateEditColumn="true" DataSourceID="sqlDataSource2" OnItemCommand="Radgrid1_ItemCommand">
 <MasterTableView DataKeyNames="CustomerID">
  <Columns>
  <telerik:GridTemplateColumn HeaderText="Dealers" HeaderStyle-Width="70px" AllowFiltering="false">
   <ItemTemplate>
     <asp:ImageButton ID="Img_Button" runat="server" CommandName="Redirect" ImageUrl='~/Images/Add.png' />
   </ItemTemplate>
  </telerik:GridTemplateColumn>
 <telerik:GridBoundColumn HeaderText="Prospect" ShowFilterIcon="True" DataField="OrderID"/>
 </Columns>
</MasterTableView>
</telerik:RadGrid>

C#:
protected void RadGrid1_ItemCommand(object sender, GridCommandEventArgs e)
 {
    if (e.CommandName == "Redirect")
     {
        GridDataItem item = (GridDataItem)e.Item;
        int index = e.Item.ItemIndex;
        RadAjaxManager1.ResponseScripts.Add(string.Format("Open('" + item.GetDataKeyValue("CustomerID").ToString() + "','" + index + "');"));
     }
}

JS:
function Open(code, index)
  {
       var radGrid = $find('<%= RadGrid1.ClientID %>'); // accessing the RadGrid
       var master = radGrid.get_masterTableView().get_dataItems()[index];
       var imgbutton = master.findElement("Img_Button"); // to get the button
       var location = $telerik.getLocation(imgbutton); // to get the location of the button in RadGrid
       var window = window.radopen(null, "RadWindow1");
       window.moveTo(location.x, location.y); //setting the window position
   }
Note: Here index is the row index.

Thanks,
Shinu.
0
Colince
Top achievements
Rank 1
answered on 07 Jun 2013, 03:18 PM
Hi Shinu!
Thank you kindly for your help.  I made small adjusment as you can see on my code below and now all is working fine. I put all inside <telerik:RadCodeBlock> to avoid error produced by <%= %>

<telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
    <script type="text/javascript">
        function Open(code, index) {
            var radGrid = $find('<%= RadGrid1.ClientID %>');
            var master = radGrid.get_masterTableView().get_dataItems()[index];
            var imgbutton = master.findElement("Ib_Button");
            var location = $telerik.getLocation(imgbutton);
            var wnd = window.radopen('DealersD.aspx?Customer=' + code, "RadWindow1");
            if (location.y > 2162)
                wnd.moveTo(350, 2162);
            else
                wnd.moveTo(350, location.y);           
        }
    </script>
    </telerik:RadCodeBlock>


 Have a nice weekend.
Colince
Tags
TreeView
Asked by
Colince
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Colince
Top achievements
Rank 1
Share this question
or