bharat kumar
Top achievements
Rank 1
bharat kumar
asked on 01 Sep 2010, 03:40 PM
Hi,
I have a radgrid on popup window having link column and set Target="_blank" but it is not working.
its opening the new page in same window instead of setting Target="_blank" in GridHyperLinkColumn of Grid.
could you please help me how to open the link in new window from popup window having grid bound within it.
please help.
4 Answers, 1 is accepted
0
Princy
Top achievements
Rank 2
answered on 02 Sep 2010, 01:37 PM
Hello Bharat,
You need to call a client method when clicking the link in the grid; for that attach "onclick" to the hyperlink. In the event handler, get refernce to RadWindow client object which shows the RadGrid. Use the GetRadWindow() method to get reference to client object of current window.
Now getting reference to the parent window is as easy as shown in code below.
var oBrowserWnd = GetRadWindow().BrowserWindow;
After getting the browser-window object open the window using oBrowserWnd.open() method, to show standard window.
Feel free write again if you need further help.
Thanks,
Princy.
You need to call a client method when clicking the link in the grid; for that attach "onclick" to the hyperlink. In the event handler, get refernce to RadWindow client object which shows the RadGrid. Use the GetRadWindow() method to get reference to client object of current window.
Now getting reference to the parent window is as easy as shown in code below.
var oBrowserWnd = GetRadWindow().BrowserWindow;
After getting the browser-window object open the window using oBrowserWnd.open() method, to show standard window.
Feel free write again if you need further help.
Thanks,
Princy.
0
bharat kumar
Top achievements
Rank 1
answered on 02 Sep 2010, 03:08 PM
Hi thanks for your reply.
but i don't understand whatever you mention.
the column in grid is as..
<telerik:GridHyperLinkColumn
SortExpression="Title"
DataNavigateUrlFields="StatusId"
DataTextField="Title"
HeaderText="Event Title"
DataType="System.String"
ItemStyle-BorderStyle="None"
ItemStyle-BorderWidth="0px"
AutoPostBackOnFilter="True"
Groupable="false"
DataNavigateUrlFormatString="../Task/Task.aspx?taskid={0}&ViewMode=ReadOnly"
ShowSortIcon="true"
AllowFiltering="true"
HeaderStyle-Width="150px"
FilterControlWidth="150px"
UniqueName="Title"
Target="_blank"
Visible="true">
</telerik:GridHyperLinkColumn>
so could we attach onclick method here and where is the hyperlink onclick event.
please help me and let me know how to achieve this.
0
Accepted
Princy
Top achievements
Rank 2
answered on 03 Sep 2010, 09:02 AM
Hello Bharat,
To attach the 'onclick' client event to HyperLinkcolumn, access that control (rendered as HyperLink) from code behind. In that event handler execute the code for changing parent page url as described in the above forum post.
C#:
Java Script:
Thanks,
Princy.
To attach the 'onclick' client event to HyperLinkcolumn, access that control (rendered as HyperLink) from code behind. In that event handler execute the code for changing parent page url as described in the above forum post.
C#:
protected
void
RadGrid1_ItemDataBound(
object
sender, GridItemEventArgs e)
{
if
(e.Item
is
GridDataItem)
{
GridDataItem item = (GridDataItem)e.Item;
HyperLink link = (HyperLink)item[
"Title"
].Controls[0];
link.Attributes.Add(
"onclick"
,
"btnClick('"
+ link.NavigateUrl +
"');return false;"
);
}
}
Java Script:
<script type=
"text/javascript"
>
function
btnClick(url) {
var
oBrowserWnd = GetRadWindow().BrowserWindow;
oBrowserWnd.open(url);
}
function
GetRadWindow() {
var
oWindow =
null
;
if
(window.radWindow)
oWindow = window.radWindow;
else
if
(window.frameElement.radWindow)
oWindow = window.frameElement.radWindow;
return
oWindow;
}
</script>
Thanks,
Princy.
0
bharat kumar
Top achievements
Rank 1
answered on 03 Sep 2010, 10:28 AM
Hi,
the code works.
Thank you very much.
the code works.
Thank you very much.