Hi,
I need help from u,
I have a gridbuttoncolumn(linkbutton),i need to open a window on oncommand,and i am opening successfully but original page is refreshing when oncommand(client events) fires..please help me how to avoid page refresh on oncommand of gridbuttoncolumn(linkbutton).
I need help from u,
I have a gridbuttoncolumn(linkbutton),i need to open a window on oncommand,and i am opening successfully but original page is refreshing when oncommand(client events) fires..please help me how to avoid page refresh on oncommand of gridbuttoncolumn(linkbutton).
6 Answers, 1 is accepted
0
Princy
Top achievements
Rank 2
answered on 13 Mar 2013, 05:00 AM
Hi,
One suggestion is that you can ajaxify the grid as shown below.
aspx:
Thanks,
Princy
One suggestion is that you can ajaxify the grid as shown below.
aspx:
<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server"> <AjaxSettings> <telerik:AjaxSetting AjaxControlID="RadGrid1"> <UpdatedControls> <telerik:AjaxUpdatedControl ControlID="RadGrid1"></telerik:AjaxUpdatedControl> </UpdatedControls> </telerik:AjaxSetting> </AjaxSettings></telerik:RadAjaxManager>Thanks,
Princy
0
Nagendra
Top achievements
Rank 1
answered on 13 Mar 2013, 05:31 AM
thanks for ur response,
But I have a usercontrol on my page which contains ajaxmangerproxy,
and i tried as u said,still it is refreshing my page,here is my oncommand code
function OnCommand(sender, args) {
if (args.get_commandName() == "InfDetail")
{
var rowIndex = args.get_commandArgument();
}
name = $find("RadGrid1").get_masterTableView().get_dataItems()[rowIndex].getDataKeyValue("Name");
if (args.get_commandName() == "InfDetail")
{
oWindow = window.open("InfGeneralDetail.aspx?InfName=" + name+"&Module=General", "mywindow", "location=1,toolbar=1,menubar=1,resizable=1,width=450,height=600,top=150, left=350");
oWindow.SetTitle("General Section:" + name);
}
}
Thanks In Advance..
But I have a usercontrol on my page which contains ajaxmangerproxy,
and i tried as u said,still it is refreshing my page,here is my oncommand code
function OnCommand(sender, args) {
if (args.get_commandName() == "InfDetail")
{
var rowIndex = args.get_commandArgument();
}
name = $find("RadGrid1").get_masterTableView().get_dataItems()[rowIndex].getDataKeyValue("Name");
if (args.get_commandName() == "InfDetail")
{
oWindow = window.open("InfGeneralDetail.aspx?InfName=" + name+"&Module=General", "mywindow", "location=1,toolbar=1,menubar=1,resizable=1,width=450,height=600,top=150, left=350");
oWindow.SetTitle("General Section:" + name);
}
}
Thanks In Advance..
0
Nagendra
Top achievements
Rank 1
answered on 14 Mar 2013, 05:32 AM
Hi Princy,
Please help as soon as possible..
Thanks.
Please help as soon as possible..
Thanks.
0
Accepted
Jayesh Goyani
Top achievements
Rank 2
answered on 14 Mar 2013, 05:59 AM
Hello,
Please try with below code snippet.
For Server side binding
For Client side Binding
Thanks,
Jayesh Goyani
Please try with below code snippet.
For Server side binding
function openWin(id) { var myWindow = window.open('', '', 'width=300,height=300'); myWindow.document.write("<p>This is 'myWindow' and id is : " + id + "</p>"); myWindow.focus(); }<telerik:GridButtonColumn ButtonType="LinkButton" Text="OPen Window" UniqueName="linkbuttonopenwindow"> </telerik:GridButtonColumn> protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e) { if (e.Item is GridDataItem) { GridDataItem item = e.Item as GridDataItem; LinkButton lnk1 = item["linkbuttonopenwindow"].Controls[0] as LinkButton; lnk1.Attributes.Add("onclick", "openWin('"+item.GetDataKeyValue("ID").ToString()+"'); return false;"); }}For Client side Binding
function RowDataBound(sender, args) { var lnkButton = args.get_item().get_cell("linkbuttonopenwindow").getElementsByTagName("a")[0]; // get link button lnkButton.onclick = function () { openWin(args.get_dataItem().ID); return false; } // add onclick event }function openWin(id) { var myWindow = window.open('', '', 'width=300,height=300'); myWindow.document.write("<p>This is 'myWindow' and id is : " + id + "</p>"); myWindow.focus(); }<telerik:GridButtonColumn ButtonType="LinkButton" Text="OPen Window" UniqueName="linkbuttonopenwindow"> </telerik:GridButtonColumn><ClientSettings> <ClientEvents OnRowDataBound="RowDataBound" /> </ClientSettings>Thanks,
Jayesh Goyani
0
Nagendra
Top achievements
Rank 1
answered on 14 Mar 2013, 07:57 AM
Very Thanks Jayesh,
It is working for only one row,if i click second row it is displaying first row window only.
but i need to display the window based on the command fires for each row..
Thanks for all..
It is working for only one row,if i click second row it is displaying first row window only.
but i need to display the window based on the command fires for each row..
Thanks for all..
0
Accepted
Hello Nagendra,
The Jayesh suggestion is what you need. You could pass the row index as well as the id. Check out the following code snippet:
Kind regards,
Kostadin
the Telerik team
The Jayesh suggestion is what you need. You could pass the row index as well as the id. Check out the following code snippet:
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e) { if (e.Item is GridDataItem) { GridDataItem item = e.Item as GridDataItem; LinkButton lnk1 = item["linkbuttonopenwindow"].Controls[0] as LinkButton; lnk1.Attributes.Add("onclick", "openWin('"+item.GetDataKeyValue("ID").ToString() + "," + item.ItemIndex "'); return false;"); }}Kind regards,
Kostadin
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.