I have a page with a RadGrid. Several functions for the grid are in a RadMenu. Several of the functions trigger a JavaScript function to open dialogs, windows, and whatnot, while another menu item does a postback to export the contents of the grid to a .csv file. Everything works fine, with the exception of the export. The menu works properly up to the point where the postback completes and the .csv begins downloading. At that point, the menu re-opens with the Export item highlighted. Is there any way to keep the menu from re-opening after the export is complete?
Here's my menu:
<
telerik:RadMenu
ID
=
"RadMenu1"
runat
=
"server"
ExpandDelay
=
"0"
CollapseDelay
=
"0"
ExpandAnimation-Type
=
"None"
CollapseAnimation-Type
=
"None"
ShowToggleHandle
=
"true"
OnItemClick
=
"RadMenu1_ItemClick"
OnClientItemClicking
=
"OnClientItemClicking"
ClickToOpen
=
"true"
Skin
=
"Windows7"
>
<
Items
>
<
telerik:RadMenuItem
Text
=
"Menu"
PostBack
=
"false"
>
<
Items
>
<
telerik:RadMenuItem
Text
=
"Save..."
/>
<
telerik:RadMenuItem
Text
=
"Save As..."
Enabled
=
"false"
Visible
=
"false"
/>
<
telerik:RadMenuItem
Text
=
"Delete"
Enabled
=
"false"
/>
<
telerik:RadMenuItem
Text
=
"|"
runat
=
"server"
IsSeparator
=
"True"
/>
<
telerik:RadMenuItem
Text
=
"Schedule..."
/>
<
telerik:RadMenuItem
Text
=
"Export"
/>
<
telerik:RadMenuItem
Text
=
"Print"
/>
<
telerik:RadMenuItem
Text
=
"|"
runat
=
"server"
IsSeparator
=
"True"
/>
<
telerik:RadMenuItem
Text
=
"Reset Grid"
/>
</
Items
>
</
telerik:RadMenuItem
>
</
Items
>
</
telerik:RadMenu
>
Here's the JavaScript that sits behind the menu:
function
OnClientItemClicking(sender , args) {
var
itemText = args.get_item().get_text();
switch
(itemText) {
case
"Save..."
:
args.set_cancel(
true
);
// Cancel postback
window.radopen(
"SaveQueryForm.aspx?KEY=<%= _queryKey %>&user=<%= _username %>&saveKey=<%= _saveKey %>"
,
"RadWindow1"
);
break
;
case
"Save As..."
:
args.set_cancel(
true
);
// Cancel postback
window.radopen(
"SaveQueryForm.aspx?KEY=<%= _queryKey %>&user=<%= _username %>"
,
"RadWindow1"
);
break
;
case
"Delete"
:
args.set_cancel(
true
);
// Cancel postback
window.radopen(
"DeleteQueryForm.aspx?savekey=<%= _saveKey %>&&user=<%= _username %>"
,
"RadWindow2"
);
break
;
case
"Schedule..."
:
args.set_cancel(
true
);
// Cancel postback
window.radopen(
"ScheduleForm.aspx?KEY=<%= _saveKey %>&user=<%= _username %>"
,
"RadWindow3"
);
break
;
case
"Print"
:
args.set_cancel(
true
);
// Cancel postback
openForm();
break
;
}
// end switch
if
(itemText !=
"Menu"
) {
closeMenu();
}
// end if
}
// end OnClientItemClicking
function
closeMenu() {
var
menu = $find(
"<%=RadMenu1.ClientID %>"
);
var
item = menu.findItemByText(
"Menu"
);
item.close();
setTimeout(
function
() {
menu.close();
}, 0);
}
// end closeMenu
The codebehind that handles the export:
protected
void
RadMenu1_ItemClick(
object
sender, RadMenuEventArgs e) {
switch
(e.Item.Text) {
case
"Export"
:
exportGridToCSV();
break
;
}
// end switch
}
// end RadMenu1_ItemClick
protected
void
exportGridToCSV() {
RadGrid1.ExportSettings.ExportOnlyData =
false
;
RadGrid1.ExportSettings.IgnorePaging =
true
;
RadGrid1.ExportSettings.OpenInNewWindow =
true
;
RadGrid1.ExportSettings.FileName = (
"Student Data Export - "
+ DateTime.Now.ToShortDateString()).Replace(
' '
,
'_'
);
RadGrid1.MasterTableView.ExportToCSV();
}
// end exportGridToCSV
Any ideas on what I can do to keep the menu from re-opening after the export?