RadWindow position

5 posts, 1 answers
  1. Colince
    Colince avatar
    11 posts
    Member since:
    Apr 2013

    Posted 05 Jun 2013 Link to this post

    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. 
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 07 Jun 2013 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Colince
    Colince avatar
    11 posts
    Member since:
    Apr 2013

    Posted 07 Jun 2013 Link to this post

    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 <%# %>.
  5. Answer
    Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 07 Jun 2013 Link to this post

    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.
  6. Colince
    Colince avatar
    11 posts
    Member since:
    Apr 2013

    Posted 07 Jun 2013 Link to this post

    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
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017