Hi everyone,
I need your help.
I added Telerik to a old project. radGrid works good, and i can open radWindow.
I have followed this demo http://demos.telerik.com/aspnet-ajax/controls/examples/integration/gridandwindow/defaultcs.aspx?product=window
But for now, i can't close the radWindow, the reason : window.radWindow and window.frameElement.radWindow from GetRadWindow() script function are undefined.
If someone can help me.
My code :
default.aspx
default.aspx.vb
Updateinfo.aspx
updateinfo.aspx.vb
But like i said, i get error of null with window.radWindow o
thanks for your help.
I need your help.
I added Telerik to a old project. radGrid works good, and i can open radWindow.
I have followed this demo http://demos.telerik.com/aspnet-ajax/controls/examples/integration/gridandwindow/defaultcs.aspx?product=window
But for now, i can't close the radWindow, the reason : window.radWindow and window.frameElement.radWindow from GetRadWindow() script function are undefined.
If someone can help me.
My code :
default.aspx
<
telerik:RadScriptManager
runat
=
"server"
EnableViewState
=
"false"
ID
=
"RadScriptManager1"
/>
<
telerik:RadCodeBlock
ID
=
"RadCodeBlock1"
runat
=
"server"
>
<
script
type
=
"text/javascript"
>
function ShowEditForm(id, rowIndex) {
var anneeID = 0;
var typeRessID = 0;
var grid = $find("<%= RadGrid1.ClientID %>");
var rowControl = grid.get_masterTableView().get_dataItems()[rowIndex].get_element();
anneeID = document.getElementById("<%= cboAnnees.ClientID %>").value;
if (document.getElementById("rbResident").checked == true) {
typeRessID = 1;
}
if (document.getElementById("rbExterne").checked == true) {
typeRessID = 2;
}
if (document.getElementById("rbAutre").checked == true) {
typeRessID = 3;
}
grid.get_masterTableView().selectItem(rowControl, true);
window.radopen("UpdateInfo.aspx?ID=" + id + "&TYPERESSID=" + typeRessID + "&ANNEEID=" + anneeID, "UserListDialog");
return false;
}
function ShowInsertForm() {
window.radopen("UpdateRessourceFrameset.aspx", "UserListDialog");
return false;
}
function refreshGrid(arg) {
if (!arg) {
$find("<%= RadAjaxManager1.ClientID %>").ajaxRequest("Rebind");
}
else {
$find("<%= RadAjaxManager1.ClientID %>").ajaxRequest("RebindAndNavigate");
}
}
</
script
>
</
telerik:RadCodeBlock
>
<
telerik:RadAjaxManager
ID
=
"RadAjaxManager1"
runat
=
"server"
OnAjaxRequest
=
"RadAjaxManager1_AjaxRequest"
>
<
AjaxSettings
>
<
telerik:AjaxSetting
AjaxControlID
=
"RadAjaxManager1"
>
<
UpdatedControls
>
<
telerik:AjaxUpdatedControl
ControlID
=
"RadGrid1"
></
telerik:AjaxUpdatedControl
>
</
UpdatedControls
>
</
telerik:AjaxSetting
>
<
telerik:AjaxSetting
AjaxControlID
=
"RadGrid1"
>
<
UpdatedControls
>
<
telerik:AjaxUpdatedControl
ControlID
=
"RadGrid1"
></
telerik:AjaxUpdatedControl
>
</
UpdatedControls
>
</
telerik:AjaxSetting
>
</
AjaxSettings
>
</
telerik:RadAjaxManager
>
<
telerik:RadGrid
OnItemCreated
=
"RadGrid1_ItemCreated"
ID
=
"RadGrid1"
runat
=
"server"
AllowPaging
=
"True"
EnableViewState
=
"true"
Width
=
"97%"
>
<
PagerStyle
Mode
=
"NumericPages"
></
PagerStyle
>
<
MasterTableView
pagesEnableViewState
=
"true"
AutoGenerateColumns
=
"False"
DataKeyNames
=
"RESS_ID"
ShowHeadersWhenNoRecords
=
"false"
ClientDataKeyNames
=
"RESS_ID"
Width
=
"100%"
PageSize
=
"20"
>
<
Columns
>
<
telerik:GridBoundColumn
DataField
=
"INFO2"
HeaderText
=
"Year"
ReadOnly
=
"True"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"INFO1"
HeaderText
=
"Name"
/>
<
telerik:GridTemplateColumn
UniqueName
=
"TemplateEditColumn"
>
<
ItemTemplate
>
<
asp:HyperLink
ID
=
"EditLink"
runat
=
"server"
Text
=
"Edit"
></
asp:HyperLink
>
</
ItemTemplate
>
</
telerik:GridTemplateColumn
>
</
Columns
>
<
CommandItemTemplate
>
<
a
href
=
"#"
onclick
=
"return ShowInsertForm();"
>No records...</
a
>
</
CommandItemTemplate
>
</
MasterTableView
>
<
ClientSettings
>
<
Selecting
AllowRowSelect
=
"false"
></
Selecting
>
</
ClientSettings
>
</
telerik:RadGrid
>
<
telerik:RadWindowManager
ID
=
"RadWindowManager1"
EnableViewState
=
"False"
runat
=
"server"
>
<
Windows
>
<
telerik:RadWindow
ID
=
"UserListDialog"
runat
=
"server"
Title
=
"Editer une ressource"
Height
=
"500px"
Width
=
"930px"
Left
=
"150px"
ReloadOnShow
=
"true"
ShowContentDuringLoad
=
"false"
Modal
=
"true"
>
</
telerik:RadWindow
>
</
Windows
>
</
telerik:RadWindowManager
>
default.aspx.vb
Protected Sub RadAjaxManager1_AjaxRequest(ByVal sender As Object, ByVal e As UI.AjaxRequestEventArgs) Handles RadAjaxManager1.AjaxRequest
If e.Argument = "Rebind" Then
RadGrid1.MasterTableView.SortExpressions.Clear()
RadGrid1.MasterTableView.GroupByExpressions.Clear()
RadGrid1.Rebind()
ElseIf e.Argument = "RebindAndNavigate" Then
RadGrid1.MasterTableView.SortExpressions.Clear()
RadGrid1.MasterTableView.GroupByExpressions.Clear()
RadGrid1.MasterTableView.CurrentPageIndex = RadGrid1.MasterTableView.PageCount - 1
RadGrid1.Rebind()
End If
End Sub
Protected Sub RadGrid1_ItemCreated(ByVal sender As Object, ByVal e As GridItemEventArgs)
If TypeOf e.Item Is GridDataItem Then
Dim editLink As HyperLink = DirectCast(e.Item.FindControl("EditLink"), HyperLink)
editLink.Attributes("href") = "#"
editLink.Attributes("onclick") = [String].Format("return ShowEditForm('{0}','{1}');", e.Item.OwnerTableView.DataKeyValues(e.Item.ItemIndex)("RESS_ID"), e.Item.ItemIndex)
End If
End Sub
Updateinfo.aspx
<
script
type
=
"text/javascript"
>
function CloseAndRebind(args) {
GetRadWindow().BrowserWindow.refreshGrid(args);
GetRadWindow().close();
}
function GetRadWindow() {
var oWindow = null;
if (window.radWindow) oWindow = window.radWindow;
else if (window.frameElement.radWindow) oWindow = window.frameElement.radWindow;
return oWindow;
}
function CancelEdit() {
window.UserListDialog.close();
}
</
script
>
....
<
asp:ScriptManager
id
=
"smUpdateRess"
runat
=
"server"
/>
<
asp:DetailsView
runat
=
"server"
ID
=
"DetailsView1"
OnItemUpdating
=
"DetailsView1_ItemUpdating"
AutoGenerateEditButton
=
"false"
AutoGenerateRows
=
"false"
GridLines
=
"None"
>
<
Fields
>
<
asp:TemplateField
>
<
EditItemTemplate
>
<
asp:Button
ID
=
"btAddContact"
runat
=
"server"
Text
=
"Save Contact"
CommandName
=
"Update"
/>
<
table
border
=
0
style
=
"width:750px"
>
<
tr
>
<
td
style
=
"height: 31px"
colspan
=
4
>
<
asp:Label
id
=
"lblInfo1"
runat
=
"server"
Text
=
"Year: "
></
asp:Label
>
<
asp:TextBox
id
=
"txtInfo2"
runat
=
"server"
Width
=
"70px"
ReadOnly
=
"true"
BackColor
=
"LightGray"
Text='<%# Container.DataItem("Info2") %>'></
asp:TextBox
>
<
asp:Label
id
=
"lblinfo2"
runat
=
"server"
Text
=
"Name:"
></
asp:Label
>
<
asp:TextBox
ID
=
"txtInfo1"
runat
=
"server"
Width
=
"70px"
ReadOnly
=
"true"
BackColor
=
"LightGray"
Text='<%# Container.DataItem("INFO1") %>'></
asp:TextBox
>
</
td
>
</
tr
>
</
table
>
</
EditItemTemplate
>
</
asp:TemplateField
>
</
Fields
>
</
asp:DetailsView
>
updateinfo.aspx.vb
on button click
ClientScript.RegisterStartupScript(Page.GetType(), "mykey", "CancelEdit();", True)
But like i said, i get error of null with window.radWindow o
r
window.frameElement.radWindow
thanks for your help.