<%
@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<%
@ Register assembly="Telerik.Web.UI" namespace="Telerik.Web.UI" tagprefix="telerik" %>
<!
DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<
html xmlns="http://www.w3.org/1999/xhtml">
<
head runat="server">
<title></title>
</
head>
<
body>
<form id="form1" runat="server">
<asp:ScriptManager ID="aspScript" runat="server">
</asp:ScriptManager>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
SelectCommand="SELECT [ProductID], [ProductName], [SupplierID], [CategoryID], [UnitsInStock], [UnitPrice] FROM [Products]">
</asp:SqlDataSource>
<telerik:RadGrid ID="grdTemplate" runat="server" DataSourceID="SqlDataSource1"
AutoGenerateColumns="true" ShowGroupPanel="True" Skin="Office2007" Height="500" Width="100%"
OnColumnCreated="grdTemplate_ColumnCreated">
<ClientSettings AllowColumnsReorder="False" AllowDragToGroup="True">
<Scrolling AllowScroll="True" UseStaticHeaders="True" />
</ClientSettings>
<MasterTableView AutoGenerateColumns="true" TableLayout="Fixed" ShowFooter="true" ShowGroupFooter="true" />
</telerik:RadGrid>
</form>
</
body>
</
html>
Code Behind
using
System;
using
System.Collections.Generic;
using
System.Web;
using
System.Web.UI;
using
System.Web.UI.WebControls;
using
Telerik.Web.UI;
public
partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
// Add the expression
grdTemplate.MasterTableView.GroupByExpressions.Add(
GridGroupByExpression.Parse("SupplierID Group By SupplierID"));
}
protected void grdTemplate_ColumnCreated(object sender, GridColumnCreatedEventArgs e)
{
// Determine the column type
if (e.Column is GridBoundColumn && e.Column.UniqueName == "UnitPrice")
{
// Set the column aggreagate
(e.Column
as GridBoundColumn).Aggregate = GridAggregateFunction.Sum;
}
}
}
<
SortExpressions
>
<
telerik:GridSortExpression
FieldName
=
"EventID"
SortOrder
=
"Descending"
/>
</
SortExpressions
>
RadAjaxManager manager = RadAjaxManager.GetCurrent(
this
.Page);
manager.ResponseScripts.Add(
"CloseWindowReload('"
+ gridReloadCommand +
"','"
+ ((itemID ==
null
) ?
"-1"
: itemID.ToString()) +
"');"
);
protected
void
SetEditorFilters()
{
// DISABLE DEFAULT FILTERS
txtContentHTML.ContentFilters = Telerik.Web.UI.EditorFilters.None;
// SET DESIRED FILTERS
txtContentHTML.EnableFilter(Telerik.Web.UI.EditorFilters.ConvertInlineStylesToAttributes);
txtContentHTML.EnableFilter(Telerik.Web.UI.EditorFilters.FixEnclosingP);
txtContentHTML.EnableFilter(Telerik.Web.UI.EditorFilters.FixUlBoldItalic);
txtContentHTML.EnableFilter(Telerik.Web.UI.EditorFilters.IndentHTMLContent);
txtContentHTML.EnableFilter(Telerik.Web.UI.EditorFilters.MakeUrlsAbsolute);
txtContentHTML.EnableFilter(Telerik.Web.UI.EditorFilters.OptimizeSpans);
txtContentHTML.EnableFilter(Telerik.Web.UI.EditorFilters.RemoveScripts);
}
<
telerik:RadGrid
ID
=
"RadGridActionItem"
runat
=
"server"
AllowSorting
=
"True"
AllowPaging
=
"true"
AllowFilteringByColumn
=
"True"
OnNeedDataSource
=
"RadGridActionItem_NeedDataSource"
OnPageIndexChanged
=
"RadGridActionItem_PageIndexChanged"
OnItemCreated
=
"RadGridAction_ItemCreated"
OnDeleteCommand
=
"RadGridActionItem_DeleteCommand"
OnInsertCommand
=
"RadGridActionItem_InsertCommand"
AllowMultiRowEdit
=
"True"
OnItemDataBound
=
"RadGridActionItem_ItemDataBound"
Width
=
"80%"
HorizontalAlign
=
"Center"
PageSize
=
"15"
EnableViewState
=
"true"
Skin
=
"Windows7"
>
<
GroupingSettings
CaseSensitive
=
"false"
/>
<
MasterTableView
AutoGenerateColumns
=
"false"
ShowFooter
=
"true"
DataKeyNames
=
"Action_Item_Id"
ClientDataKeyNames
=
"Action_Item_Id"
CommandItemDisplay
=
"Top"
Width
=
"100%"
HorizontalAlign
=
"Center"
EditMode
=
"Batch"
>
protected
void
RadMenu1_ItemClick(
object
sender, RadMenuEventArgs e)
{
// Right click context menu selection event.
int
radGridClickRowIndex;
string
actionItemId;
bool
copied =
true
;
// Get row index and Action_Item_Id associated with row
radGridClickRowIndex = Convert.ToInt32(Request.Form[
"radGridClickedRowIndex"
]);
actionItemId = RadGridActionItem.MasterTableView.DataKeyValues[radGridClickRowIndex][
"Action_Item_Id"
].ToString();
switch
(e.Item.Text)
{
case
"Copy"
:
Response.Redirect(
"NewActionItem.aspx?ActionId="
+ actionItemId +
"&IsCopied="
+ copied);
break
;
}
}
<script type=
"text/javascript"
>
function
RowDblClick(sender, args) {
var
dblClick;
dblClick =
true
;
var
index = args.get_itemIndexHierarchical();
var
updateActionId = args.getDataKeyValue(
"Action_Item_Id"
);
window.location.href =
"NewActionItem.aspx?DblClick="
+ dblClick +
"&UpdateActionId="
+ updateActionId;
}
</script>