I had this problem before and never got and answer to it when i submitted a help ticket and now I am back to it becuase I have another case where I need to impliment it in a radgrid and cannot go back to a asp grid. What is happening is that I need a link button or hyperlink button on a radgrid that when they click on it it opens in a new window a page to email personnel. problem is when I do this it forwards the page to the email name or site in this case, need it to stay at grid and open a the email page and pass a variable to it.
<telerik:GridTemplateColumn HeaderText="MAC #">
<ItemTemplate>
<asp:LinkButton ID="lnkEmail" runat="server" CommandName="Email" CommandArgument='<% #Bind("intUserId") %>' text='<% #Bind("strMacNum") %>'
ToolTip="Email the IMO"></asp:LinkButton>
</ItemTemplate>
</telerik:GridTemplateColumn>
Right now its redirecting but i cannot have this, just needs to open the email page in another window while staying on grid page.
If (e.CommandName = "Email") Then
Dim RecordId As Integer = e.CommandArgument
Response.Redirect("Email.aspx?Email=" & RecordId)
End If
also tried this but no go, forwards the grid to email page.
ClientScript.RegisterStartupScript(Me.GetType(), "OpenWin", "<script>openNewWin('" & url & "')</script>")
My Scenario
I have a grid which allows inline editing. When the user clicks a hyperlink in any row I open a radwindow. The hyperlink is a template cell and I open the RadWindow via javascript which all works fine except that I need to be able to save the row before opening the radwindow if it is in edit mode because I'm passing in the unique id of the row and if it is a new row I need to perform the insert command first so that the Id is generated on the server. The data is in SQL and the Id is an Identity column. I'm also using automatic updates on the grid.
My Question
Is it possible to save the row and invoke the insert command when the user clicks the hyperlink/template cell? If so can you provide sample code on how this could be done from javascript or server side code. Both would be idea. Thank you!
Here is the template column used to open the RadWindow
<telerik:GridTemplateColumn HeaderText="Selection Options" UniqueName="SelectionOptions" AllowFiltering="false">
<ItemTemplate><a href="#"
onclick='openAnswerOptionsWindow('<%# DataBinder.Eval(Container.DataItem, "LCFormMetadataId") %>'); return false;'>
SelectionOptions</a></ItemTemplate>
</telerik:GridTemplateColumn>
Here is the javascript I use to open the RadWindow
function openLCFormManagementWindow() {
var oWnd = radopen("LCFormMaintenance.aspx");
oWnd.Center();
}
function
SplitterLoaded(splitter, arg) {
var
scheduler = $find(
"<%= RadScheduler1.ClientID %>"
);
var
hauteur = window.innerHeight - 71;
var
slots = (((scheduler.get_dayViewSettings().dayEndTime / 1000) / 60) - ((scheduler.get_dayViewSettings().dayStartTime / 1000) / 60)) / 15
scheduler.set_rowHeight(
""
+ Math.round(hauteur / slots) +
"px"
);
var
pane = splitter.getPaneById(
'RadPane1'
);
var
height = pane.getContentElement().scrollHeight;
splitter.set_height(splitter.get_height() - pane.get_height() + height);
pane.set_height(height);
}
scheduler.set_rowHeight(
""
+ Math.round(hauteur / slots) +
"px"
);
<%@ Page Language="VB" AutoEventWireup="true" CodeFile="Default.aspx.vb" Inherits="_Default" %>
<%@ Register Assembly="Telerik.Web.UI, Version=2008.1.415.20, Culture=neutral, PublicKeyToken=121fae78165ba3d4"
Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<div>
<telerik:RadToolBar ID="RadToolBar1" runat="server">
<CollapseAnimation Duration="200" Type="OutQuint" />
<Items>
<telerik:RadToolBarButton runat="server" Text="Download Excel" Value="DOWNLOADEXCEL">
</telerik:RadToolBarButton>
<telerik:RadToolBarButton runat="server" Text="Download PDF" Value="DOWNLOADPDF">
</telerik:RadToolBarButton>
</Items>
</telerik:RadToolBar>
</div>
</form>
</body>
</html>
------------------------------------------------------------------------
---------------Default.aspx.vb--------------------------------------------
Partial Class _Default
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
End Sub
Protected Sub RadToolBar1_ButtonClick(ByVal sender As Object, ByVal e As Telerik.Web.UI.RadToolBarEventArgs) Handles RadToolBar1.ButtonClick
If e.Item.Value = "DOWNLOADEXCEL" Then
Dim file As System.IO.FileInfo = New System.IO.FileInfo("C:\Test.jpg")
Response.Clear()
Response.AddHeader("Content-Disposition", "attachment; filename=" & file.Name)
Response.AddHeader("Content-Length", file.Length.ToString())
Response.ContentType = "application/octet-stream"
Response.WriteFile(file.FullName)
Response.End() 'if file does not exist
Else
Dim file As System.IO.FileInfo = New System.IO.FileInfo("C:\Test.png")
Response.Clear()
Response.AddHeader("Content-Disposition", "attachment; filename=" & file.Name)
Response.AddHeader("Content-Length", file.Length.ToString())
Response.ContentType = "application/octet-stream"
Response.WriteFile(file.FullName)
Response.End() 'if file does not exist
End If
End Sub
End Class
------------------------------------------------------------------------
Please help me how to solve this problem.
Thanks & Regards,
Louis
<
telerik:RadScriptBlock
ID
=
"RadScriptBlock1"
runat
=
"server"
>
<
script
type
=
"text/javascript"
>
function Lancar_Tarefa(id) {
window.radopen("Agenda_Tarefa_Novo.aspx?Id=" + id, "AgendaTarefa");
}
function Msg(msg, tipo) {
window.radopen("Msg.aspx?Texto=" + msg + "&Tipo=" + tipo, "Msg");
return false;
}
</
script
>
</
telerik:RadScriptBlock
>
<
telerik:RadAjaxManager
ID
=
"RadAjaxManager1"
runat
=
"server"
>
<
AjaxSettings
>
<
telerik:AjaxSetting
AjaxControlID
=
"btnFiltrar"
>
<
UpdatedControls
>
<
telerik:AjaxUpdatedControl
ControlID
=
"PanelAgenda"
LoadingPanelID
=
"RadAjaxLoadingPanel1"
/>
<
telerik:AjaxUpdatedControl
ControlID
=
"pnGrid"
LoadingPanelID
=
"RadAjaxLoadingPanel1"
/>
</
UpdatedControls
>
</
telerik:AjaxSetting
>
</
AjaxSettings
>
</
telerik:RadAjaxManager
>
<
telerik:RadAjaxLoadingPanel
ID
=
"RadAjaxLoadingPanel1"
Skin
=
"Windows7"
runat
=
"server"
></
telerik:RadAjaxLoadingPanel
>
<
telerik:RadButton
ID
=
"btnFiltrar"
runat
=
"server"
Skin
=
"Web20"
Text
=
"Filtrar"
Width
=
"90px"
style
=
"margin-right:10px;"
>
<
Icon
PrimaryIconUrl
=
"../../Icones/VizualizarGrid2.png"
/>
</
telerik:RadButton
>
<
asp:Panel
ID
=
"pnGrid"
runat
=
"server"
>
<
telerik:RadGrid
ID
=
"gridAgenda"
runat
=
"server"
Width
=
"710px"
Height
=
"462px"
Skin
=
"Outlook"
AutoGenerateColumns
=
"False"
CellSpacing
=
"0"
GridLines
=
"None"
>
<
ClientSettings
>
<
Selecting
AllowRowSelect
=
"True"
/>
<
Scrolling
AllowScroll
=
"True"
UseStaticHeaders
=
"True"
/>
</
ClientSettings
>
<
MasterTableView
>
<
CommandItemSettings
ExportToPdfText
=
"Export to PDF"
/>
<
RowIndicatorColumn
FilterControlAltText
=
"Filter RowIndicator column"
Visible
=
"True"
>
<
HeaderStyle
Width
=
"20px"
/>
</
RowIndicatorColumn
>
<
ExpandCollapseColumn
FilterControlAltText
=
"Filter ExpandColumn column"
Visible
=
"True"
>
<
HeaderStyle
Width
=
"20px"
/>
</
ExpandCollapseColumn
>
<
Columns
>
<
telerik:GridButtonColumn
ButtonType
=
"ImageButton"
CommandName
=
"Select"
FilterControlAltText
=
"Filter column column"
ImageUrl
=
"~/Icones/Grid.gif"
UniqueName
=
"column"
>
<
HeaderStyle
Width
=
"35px"
/>
<
ItemStyle
HorizontalAlign
=
"Center"
Width
=
"35px"
/>
</
telerik:GridButtonColumn
>
<
telerik:GridDateTimeColumn
DataField
=
"DFdata_inicio"
FilterControlAltText
=
"Filter DFdata_inicio column"
HeaderText
=
"Data/Hora"
UniqueName
=
"DFdata_inicio"
>
<
HeaderStyle
Width
=
"120px"
/>
<
ItemStyle
Width
=
"120px"
/>
</
telerik:GridDateTimeColumn
>
<
telerik:GridBoundColumn
DataField
=
"DFid_agenda_relacionada"
FilterControlAltText
=
"Filter DFid_agenda_relacionada column"
HeaderText
=
"ID"
UniqueName
=
"DFid_agenda_relacionada"
>
<
HeaderStyle
Width
=
"50px"
/>
<
ItemStyle
Width
=
"50px"
/>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"DFfase"
FilterControlAltText
=
"Filter DFfase column"
HeaderText
=
"Fase"
UniqueName
=
"DFfase"
Visible
=
"false"
>
<
HeaderStyle
Width
=
"40px"
/>
<
ItemStyle
Width
=
"40px"
/>
</
telerik:GridBoundColumn
>
<
telerik:GridTemplateColumn
HeaderText
=
"Fase"
UniqueName
=
"Fase"
>
<
ItemTemplate
>
<
asp:Panel
ID
=
"CorFase"
runat
=
"server"
Height
=
"20px"
Width
=
"20px"
/>
</
ItemTemplate
>
<
HeaderStyle
Width
=
"40px"
/>
<
ItemStyle
HorizontalAlign
=
"Center"
Width
=
"40px"
/>
</
telerik:GridTemplateColumn
>
<
telerik:GridBoundColumn
DataField
=
"DFusuario_agenda"
FilterControlAltText
=
"Filter DFusuario_agenda column"
HeaderText
=
"Agenda"
UniqueName
=
"DFusuario_agenda"
>
<
HeaderStyle
Width
=
"85px"
/>
<
ItemStyle
Width
=
"85px"
/>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"DFtarefa"
FilterControlAltText
=
"Filter DFtarefa column"
HeaderText
=
"Tarefa"
UniqueName
=
"DFtarefa"
>
<
HeaderStyle
Width
=
"200px"
/>
<
ItemStyle
Width
=
"200px"
/>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"DFenviado_por"
FilterControlAltText
=
"Filter DFenviado_por column"
HeaderText
=
"Enviado Por"
UniqueName
=
"DFenviado_por"
>
<
HeaderStyle
Width
=
"85px"
/>
<
ItemStyle
Width
=
"85px"
/>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"DFcliente"
FilterControlAltText
=
"Filter DFcliente column"
HeaderText
=
"Cliente"
UniqueName
=
"DFcliente"
>
<
HeaderStyle
Width
=
"200px"
/>
<
ItemStyle
Width
=
"200px"
/>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"DFid_agenda"
FilterControlAltText
=
"Filter DFid_agenda column"
HeaderText
=
"DFid_agenda"
UniqueName
=
"DFid_agenda"
Visible
=
"False"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"DFid_usuario_agenda"
FilterControlAltText
=
"Filter DFid_usuario_agenda column"
HeaderText
=
"DFid_usuario_agenda"
UniqueName
=
"DFid_usuario_agenda"
Visible
=
"False"
>
</
telerik:GridBoundColumn
>
</
Columns
>
<
EditFormSettings
>
<
EditColumn
FilterControlAltText
=
"Filter EditCommandColumn column"
>
</
EditColumn
>
</
EditFormSettings
>
</
MasterTableView
>
<
FilterMenu
EnableImageSprites
=
"False"
>
</
FilterMenu
>
</
telerik:RadGrid
>
</
asp:Panel
>
Private
Sub
gridAgenda_SelectedIndexChanged(sender
As
Object
, e
As
System.EventArgs)
Handles
gridAgenda.SelectedIndexChanged
If
gridAgenda.SelectedItems.Count > 0
Then
For
Each
Row
As
GridDataItem
In
gridAgenda.SelectedItems
If
cmbUsuario.SelectedValue =
""
Then
clsVariavel_Sessao.Agenda_IdUsuario = Row(
"DFid_usuario_agenda"
).Text
TableRetorno = clsConexao.Executar_Retornar(
"SELECT lcase(DFnome), lcase(DFemail) FROM TBusuario WHERE DFid_usuario = "
& Row(
"DFid_usuario_agenda"
).Text)
clsVariavel_Sessao.Agenda_Usuario = TableRetorno(0)(0)
clsVariavel_Sessao.Agenda_UsuarioLogin = TableRetorno(0)(1)
End
If
ScriptManager.RegisterClientScriptBlock(
Me
, [
GetType
](),
"Tarefa"
,
"Lancar_Tarefa("
& Row(
"DFid_agenda"
).Text &
")"
,
True
)
Next
End
If
Exit
Sub
Erro:
MensagemBox(
"Operação cancelada."
, TipoMsg.Erro, Page)
Call
Gravar_Log_Erro(Err.Description, clsVariavel_Sessao.Erro, clsVariavel_Sessao.Default_UsuarioLogadoID, clsVariavel_Sessao.Default_UsuarioLogadoLogin, clsVariavel_Sessao.Default_UsuarioLogadoIP, clsVariavel_Sessao.SiteMaster_FormularioID, clsVariavel_Sessao.SiteMaster_urlWithSessionID,
"gridAgenda_SelectedIndexChanged"
)
End
Sub
function
checkFound(sender, args) {
var
count = sender.get_items().get_count()
if
(count <= 0 && sender.get_text().length > 0) {
var
tt = $find(
'<%=tt_searchArea_empty.ClientID %>'
);
tt.set_text(
"No results found for '"
+ sender.get_text() +
"'"
);
tt.show();
}
else
{
hideAreaEmptyToolTip();
}
}
function
hideAreaEmptyToolTip() {
var
tt = $find(
'<%=tt_searchArea_empty.ClientID %>'
);
tt.hide();
}