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

RadButton on a RadGrid does not open a RadWindow

9 Answers 442 Views
Window
This is a migrated thread and some comments may be shown as answers.
pradip
Top achievements
Rank 1
pradip asked on 06 Dec 2010, 11:31 AM
Hi all,

I am working with Rad window control  in Rad grid.
 when i am using rad button to pop up rad window . rad window  doesn't  pop up .
but when i am using simple HTML tags like anchor tag to pop up rad window its working fine .
Please give me solution on this problem.why rad window not compatible with rad button.

9 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 06 Dec 2010, 12:39 PM
Hello,


I am not quite sure about the scenario that you are trying or about your code. But, could you try attaching client event to RadButton and open the window using client method?

The documentation shows more on how to open window from client side.
http://www.telerik.com/help/aspnet-ajax/window_programmingopening.html


-Shinu.
0
pradip
Top achievements
Rank 1
answered on 06 Dec 2010, 03:18 PM
hi shinu thanks for u r reply but i am already used all client side events

like onclientclicked and onclientclicking event .but these stuff not useful for me

waiting for another ans ( for inside the rad grid )

pradip
0
Georgi Tunev
Telerik team
answered on 07 Dec 2010, 03:08 PM
Hi pradip,

Please provide more details about your setup. How exactly do you use the RadButton control and how do you open RadWindow with it? What happens if you replace RadButton with a standard asp:Button control?

Greetings,
Georgi Tunev
the Telerik team
Browse the vast support resources we have to jumpstart your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
0
pradip
Top achievements
Rank 1
answered on 07 Dec 2010, 03:25 PM
HI

Actually i am using Radwindow within Radgrid. when I am using Radbutton to popup the Radwindow. popup not showing using
below function
 function openWin()
    {     
       var oWnd = radopen("addproduct.aspx", "AddProduct");             
    }

i am using these function on radbutton onclicking  and onclicked event  Event. popup not showing.

 <asp:Button ID="btnnew" runat="server" OnClientClick="openWin()" />
but when  Asp:button inserted within <CommandItemTemplate> of Rad grid . they didnot show popup.


but when i am using anchor tag simple html then this tag is usefull for me to show popup..




0
Georgi Tunev
Telerik team
answered on 10 Dec 2010, 03:02 PM
Hello Pradip,

I attached a small sample that show how to use RadButton in RadGrid. In it, when you click on the RadButton, you will fire a JavaScript function that alerts some values sent from the server. If you want to use RadWindow, you can call it in that JavaScript function and pass the arguments to it if needed.


Best wishes,
Georgi Tunev
the Telerik team
Browse the vast support resources we have to jumpstart your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
0
pradip
Top achievements
Rank 1
answered on 13 Dec 2010, 10:27 AM
Hi

Your small project working fine on GridBoundColumn but not useful for me when i am working in CommandItemTemplate with radwindow.

I am using radbutton in CommandItemTemplate , on radbutton + rad window   is not working.

Please give me solution asap.



0
pradip
Top achievements
Rank 1
answered on 13 Dec 2010, 10:27 AM
Hi

Your small project working fine on GridBoundColumn but not useful for me when i am working in CommandItemTemplate with radwindow.

I am using radbutton in CommandItemTemplate , on radbutton + rad window   is not working.

Please give me solution asap.


0
pradip
Top achievements
Rank 1
answered on 13 Dec 2010, 10:47 AM
I attached your project  with modified code please find the attachment.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
 
    protected void RadGrid1_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
    {
        System.Data.DataTable tbl = new System.Data.DataTable();
        System.Data.DataColumn col = new System.Data.DataColumn("ID");
        col.DataType = typeof(int);
        tbl.Columns.Add(col);
        col = new System.Data.DataColumn("Name");
        col.DataType = typeof(string);
        tbl.Columns.Add(col);
        col = new System.Data.DataColumn("Group");
        col.DataType = typeof(string);
        tbl.Columns.Add(col);
 
        int size = 20;
        int maxLen = size.ToString().Length;
        for (int i = 1; i <= size; i++)
        {
            tbl.Rows.Add(new object[] { i, "Name " + i.ToString("D" + maxLen), "Group " + i % 5 });
        }
        RadGrid1.DataSource = tbl;
    }
 
    protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
    {
        if (e.Item is GridDataItem)
        {
            //get the values that you need - in this case we will take the text of the row's cells
            GridDataItem item = e.Item as GridDataItem;
            string idField = e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["ID"].ToString();
            string nameField = item["Name"].Text;
            string groupField = item["Group"].Text;
 
            //cast the button. IMPORTANT - since we will use client-side code, set AutoPostBack=false for the RadButton
            Telerik.Web.UI.RadButton EditButton = (Telerik.Web.UI.RadButton)e.Item.FindControl("RadButton1");
 
            //foreach (GridDataItem item2 in RadGrid1.MasterTableView.Items)
            //{
            //    RadButton btn = (RadButton)item2.FindControl("radbtntemplate");
            //    btn.OnClientClicked = "alertValues1";
            //}
             
             
            Telerik.Web.UI.RadButton template = (Telerik.Web.UI.RadButton)e.Item.FindControl("radbtntemplate");
             
            //approach #1
            //use OnClientClicked and set it in anonymous function.
            //EditButton.OnClientClicked = String.Format(@"function(){{alert('ID: {0} \nName: {1} \nGroup: {2}');}}", idField, nameField, groupField);
 
            //approach #2
            //assign onclick attribute and call the JavaScript function in it (the attribute will be applied on the A element that RadButton uses for styling
            //EditButton.Attributes["onclick"] = String.Format(@"alert('ID: {0} \nName: {1} \nGroup: {2}');", idField, nameField, groupField);
 
 
            //approach #3
            //use the CommandArgument property to assign optional parameters passed to the command
            EditButton.CommandArgument = idField + "," + nameField + "," + groupField;
            EditButton.OnClientClicked = "alertValues";
 
             
             
             
             
             
        }
    }
</script>
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <telerik:RadScriptManager ID="ScriptManager1" runat="server">
    </telerik:RadScriptManager>
    <telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="Server" />
    <telerik:RadGrid ID="RadGrid1" runat="server" OnNeedDataSource="RadGrid1_NeedDataSource"
        OnItemDataBound="RadGrid1_ItemDataBound">
        <MasterTableView AutoGenerateColumns="False" DataKeyNames="ID" ClientDataKeyNames="ID"
            Width="100%" CommandItemDisplay="Top" PageSize="5">
            <Columns>
                <telerik:GridBoundColumn DataField="ID" HeaderText="ID" ReadOnly="True" SortExpression="ID"
                    UniqueName="ID">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="Name" HeaderText="Name" ReadOnly="True" SortExpression="Name"
                    UniqueName="Name">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="Group" HeaderText="Group" ReadOnly="True" SortExpression="Group"
                    UniqueName="Group">
                </telerik:GridBoundColumn>
                <telerik:GridTemplateColumn UniqueName="TemplateEditColumn">
                    <ItemTemplate>
                        <telerik:RadButton ID="RadButton1" AutoPostBack="false" runat="server" Text="Show Data On Client">
                        </telerik:RadButton>
                    </ItemTemplate>
                </telerik:GridTemplateColumn>              
            </Columns>
            <CommandItemTemplate>
            <telerik:RadButton ID="radbtntemplate" runat="server" Text="run" OnClientClicked="openWin()">          
            </telerik:RadButton>
            </CommandItemTemplate>
        </MasterTableView>
    </telerik:RadGrid>
    <telerik:RadWindowManager ID="RadWindowManager2" runat="server">
        <Windows>
            <telerik:RadWindow ID="AddProduct" runat="server" 
                Behaviors="Close" NavigateUrl="home.aspx"
                Modal="true" Height="350px" Width="600px" ShowContentDuringLoad="false"
                VisibleStatusbar="false" ReloadOnShow="true">
            </telerik:RadWindow>
        </Windows>
    </telerik:RadWindowManager>
    <script type="text/javascript">
 
        function alertValues(sender, args)
        {
            //get the argument passed from the server.
            var arguments = sender.get_commandArgument();
            //since it is an array, we need to split it
            var params_array = arguments.split(",");
            //use the values
            alert("ID: " + params_array[0] + "\nName: " + params_array[1] + "\nGroup: " + params_array[2]);
        }
 
        function alertValues1() {
 
            alert("hi ...........");
        }
 
        function openWin() {
             
            var oWnd = radopen("home.aspx", "AddProduct");
 
        }
 
 
    </script>
    </form>
</body>
</html>

i am trying to open radwindow  using client sideopenWin() java script function   on rad button but its not working .
rad button under Command template  not working properly..
onclicked event also not working .
please give me solution .





0
Cori
Top achievements
Rank 2
answered on 13 Dec 2010, 04:52 PM
Hello Pradip,

Since you the RadButton inside of a RadAjaxPanel (it seems to have issue when ajaxed) you need to set UseSubmitBehviour="false", so it will postback. I would assume that is the issue with the RadButton in the CommandItemTemplate.

To call you openWin function using the RadButton, you need to change the method signature to openWin(sender, args), in order to assign it the RadButton's OnClientClicked event.

I hope that helps.
Tags
Window
Asked by
pradip
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
pradip
Top achievements
Rank 1
Georgi Tunev
Telerik team
Cori
Top achievements
Rank 2
Share this question
or