We use Telerik's grid for VS2008 and added context menu to it. The code looks as following:
Markup:
Code behind:
JavaScript:
I'd like to show popup window when click to "Export To Excel"" option:
The execution of program should be stopped and wait for selecting option in combo box in popup window. After selecting we click "OK" and the control of program execution is returned back to ASP.NET code. How can I do that?
Thank in advance.
Goran
Markup:
<
telerik:RadGrid
ID
=
"RadGrid1"
runat
=
"server"
Width
=
"100%"
DataSourceID
=
"SqlDataSource1"
AllowAutomaticDeletes
=
"true"
AllowAutomaticInserts
=
"true"
AllowAutomaticUpdates
=
"true"
AutoGenerateColumns
=
"false"
AllowMultiRowSelection
=
"true"
>
<
MasterTableView
PageSize
=
"10"
AllowPaging
=
"True"
Width
=
"100%"
DataKeyNames
=
"ContinentID"
DataSourceID
=
"SqlDataSource1"
EditMode
=
"InPlace"
>
<
Columns
>
<
telerik:GridClientSelectColumn
UniqueName
=
"checkBox"
></
telerik:GridClientSelectColumn
>
<
telerik:GridBoundColumn
HeaderText
=
"ContinentID"
DataField
=
"ContinentID"
></
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
HeaderText
=
"ContinentName"
DataField
=
"ContinentName"
></
telerik:GridBoundColumn
>
</
Columns
>
</
MasterTableView
>
<
ClientSettings
>
<
ClientEvents
OnRowContextMenu
=
"RowContextMenu"
></
ClientEvents
>
<
Selecting
AllowRowSelect
=
"true"
></
Selecting
>
</
ClientSettings
>
</
telerik:RadGrid
>
Code behind:
protected
void
contextMenu_ItemClick(
object
sender, RadMenuEventArgs e)
{
int
rowIndex =
int
.Parse(HiddenField1.Value);
switch
(e.Item.Text)
{
case
"Edit"
:
RadGrid1.Items[rowIndex].Edit =
true
;
RadGrid1.Rebind();
break
;
case
"Add"
:
RadGrid1.MasterTableView.IsItemInserted =
true
;
RadGrid1.Rebind();
break
;
case
"Delete"
:
RadGrid1.MasterTableView.PerformDelete(RadGrid1.Items[rowIndex]);
break
;
case
"Export To Excel"
:
RadGrid1.MasterTableView.GetColumn(
"checkBox"
).Visible =
false
;
RadGrid1.ExportSettings.ExportOnlyData =
true
;
RadGrid1.ExportSettings.OpenInNewWindow =
true
;
RadGrid1.MasterTableView.ExportToExcel();
break
;
}
}
JavaScript:
function
RowContextMenu(sender, eventArgs, menu, hiddenField) {
var
evt = eventArgs.get_domEvent();
if
(evt.target.tagName ==
"INPUT"
|| evt.target.tagName ==
"A"
) {
return
;
}
var
index = eventArgs.get_itemIndexHierarchical();
hiddenField.value = index;
menu.show(evt);
evt.cancelBubble =
true
;
evt.returnValue =
false
;
if
(evt.stopPropagation) {
evt.stopPropagation();
evt.preventDefault();
}
}
I'd like to show popup window when click to "Export To Excel"" option:
case
"Export To Excel"
:
The execution of program should be stopped and wait for selecting option in combo box in popup window. After selecting we click "OK" and the control of program execution is returned back to ASP.NET code. How can I do that?
Thank in advance.
Goran