or

<telerik:RadTreeView ID="tvwCSI" runat="server" BorderColor="Silver" BorderStyle="Solid"
CssClass="box" CheckBoxes="True" DataTextField="Description" DataValueField="ID"
Height="250" Skin="Hay" Width="300px">
<CollapseAnimation Duration="1" Type="OutQuint" />
<ExpandAnimation Duration="1" />
</telerik:RadTreeView>


<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %><!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> <telerik:RadStyleSheetManager id="RadStyleSheetManager1" runat="server" /></head><body> <form id="form1" runat="server"> <telerik:RadScriptManager ID="RadScriptManager1" runat="server"> <Scripts> <%--Needed for JavaScript IntelliSense in VS2010--%> <%--For VS2008 replace RadScriptManager with ScriptManager--%> <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.Core.js" /> <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQuery.js" /> <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQueryInclude.js" /> </Scripts> </telerik:RadScriptManager> <script type="text/javascript"> //Put your JavaScript code here. </script> <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server"> </telerik:RadAjaxManager> <div> <telerik:RadGrid runat="server" ID="RadGrid" AutoGenerateColumns="false" AllowCustomPaging="true" AllowPaging="true" PageSize="50" AllowFilteringByColumn="true" EnableLinqExpressions="false"> <GroupingSettings CaseSensitive="False" /> <ClientSettings> <Selecting AllowRowSelect="True" /> <Scrolling AllowScroll="True" ScrollHeight="100%" UseStaticHeaders="True" /> </ClientSettings> <PagerStyle AlwaysVisible="True" /> <MasterTableView OverrideDataSourceControlSorting="True"> <NoRecordsTemplate> </NoRecordsTemplate> <Columns> <%--Some columns here--%> </Columns> </MasterTableView> </telerik:RadGrid> </div> </form></body></html>Imports Telerik.Web.UIImports System.DataPartial Class _Default Inherits System.Web.UI.Page Protected Sub RadGrid_NeedDataSource(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridNeedDataSourceEventArgs) Handles RadGrid.NeedDataSource Dim VirtualItemCount As Integer = GetDatasVirtualItemsCount(RadGrid.MasterTableView.FilterExpression) RadGrid.MasterTableView.VirtualItemCount = VirtualItemCount RadGrid.VirtualItemCount = VirtualItemCount Dim startIndex As Integer = IIf((ShouldApplySortFilterOrGroup()), 0, RadGrid.CurrentPageIndex * RadGrid.PageSize) Dim pageSize As Integer = IIf((ShouldApplySortFilterOrGroup()), VirtualItemCount, RadGrid.PageSize) RadGrid.DataSource = GetDatas(startIndex, pageSize, RadGrid.MasterTableView.FilterExpression) End Sub Private isGrouping As Boolean = False Protected Sub RadGrid1_GroupsChanging(ByVal source As Object, ByVal e As GridGroupsChangingEventArgs) isGrouping = True If e.Action = GridGroupsChangingAction.Ungroup AndAlso RadGrid.CurrentPageIndex > 0 Then isGrouping = False End If End Sub Public Function ShouldApplySortFilterOrGroup() As Boolean Return RadGrid.MasterTableView.FilterExpression <> "" _ OrElse (RadGrid.MasterTableView.GroupByExpressions.Count > 0 OrElse isGrouping) OrElse RadGrid.MasterTableView.SortExpressions.Count > 0 End Function Private Function GetDatas(ByVal startIndex As Integer, ByVal pageSize As Integer, ByVal FilterExpression As String) As DataTable ' ------------ ' Some Code that generates a datatable considering both CustomPaging and Filtering ' ------------ Return New DataTable End Function Private Function GetDatasVirtualItemsCount(ByVal FilterExpression As String) As Integer ' ------------ ' Some Code that count the number of rows considering Filtering ' ------------ Return -1 End FunctionEnd ClassImports Telerik.Web.UIImports System.DataPartial Class _Default2 Inherits System.Web.UI.Page Protected Sub RadGrid_NeedDataSource(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridNeedDataSourceEventArgs) Handles RadGrid.NeedDataSource Dim VirtualItemCount As Integer = GetDatasVirtualItemsCount(RadGrid.MasterTableView.FilterExpression) RadGrid.MasterTableView.VirtualItemCount = VirtualItemCount RadGrid.VirtualItemCount = VirtualItemCount Dim startIndex As Integer = RadGrid.CurrentPageIndex * RadGrid.PageSize Dim pageSize As Integer = RadGrid.PageSize RadGrid.DataSource = GetDatas(startIndex, pageSize, RadGrid.MasterTableView.FilterExpression) End Sub Private Function GetDatas(ByVal startIndex As Integer, ByVal pageSize As Integer, ByVal FilterExpression As String) As DataTable ' ------------ ' Some Code that generates a datatable considering both CustomPaging and Filtering ' ------------ Return New DataTable End Function Private Function GetDatasVirtualItemsCount(ByVal FilterExpression As String) As Integer ' ------------ ' Some Code that count the number of rows considering Filtering ' ------------ Return -1 End FunctionEnd Class<telerik:RadGrid ID="RadGrid1" runat="server" AllowPaging="True" GridLines="None" AllowFilteringByColumn="True" AllowSorting="True" Skin="Windows7" OnItemDataBound="RadGrid1_ItemDataBound" OnSelectedIndexChanged="RadGrid1_SelectedIndexChanged" DataSourceID="odsTransactionsValidees" onprerender="RadGrid1_PreRender" OnExcelMLExportStylesCreated="RadGrid1_ExcelMLExportStylesCreated" onexcelmlexportrowcreated="RadGrid1_ExcelMLExportRowCreated">...
<ExportSettings OpenInNewWindow="True" ExportOnlyData="True" FileName="ExportValidees" IgnorePaging="true" Excel-Format="ExcelML" />....
<MasterTableView DataSourceID="odsTransactionsValidees" AutoGenerateColumns="False" NoMasterRecordsText="Pas de transactions." Font-Size="Medium" UseAllDataFields="true" DataKeyNames="ID_TRANSACTION,DOUTE_CLASSIFICATION" OverrideDataSourceControlSorting="true" AllowNaturalSort="true" CommandItemDisplay="Bottom"> <CommandItemSettings ExportToExcelText="Export Excel" ShowExportToExcelButton="False" ShowAddNewRecordButton="False" ShowRefreshButton="False" />....
</telerik:RadGrid>....
protected void RadGrid1_ExcelMLExportStylesCreated(object source, GridExportExcelMLStyleCreatedArgs e) { // ajoute les bordures de cellule BorderStylesCollection borders = new BorderStylesCollection(); BorderStyles borderStyle = null; for (int i = 1; i <= 4; i++) { borderStyle = new BorderStyles(); borderStyle.PositionType = (PositionType)i; borderStyle.Color = System.Drawing.Color.Black; borderStyle.LineStyle = LineStyle.Continuous; borderStyle.Weight = 1.0; borders.Add(borderStyle); } foreach (StyleElement style in e.Styles) { foreach (BorderStyles border in borders) { style.Borders.Add(border); } } StyleElement style1 = new StyleElement("MyStyleWhite"); style1.InteriorStyle.Pattern = InteriorPatternType.Solid; style1.InteriorStyle.Color = System.Drawing.Color.White; e.Styles.Add(style1); StyleElement style2 = new StyleElement("MyStyleOrange"); style2.InteriorStyle.Pattern = InteriorPatternType.Solid; style2.InteriorStyle.Color = System.Drawing.Color.Orange; e.Styles.Add(style2); }
protected void RadGrid1_ExcelMLExportRowCreated(object sender, GridExportExcelMLRowCreatedArgs e) { string typeTransaction = hidType.Value; if (e.RowType == GridExportExcelMLRowType.DataRow) { if (typeTransaction == TypeTransactionValide || typeTransaction == TypeTransactionValideReseau) { string style; foreach (GridDataItem item in RadGrid1.MasterTableView.Items) { string color = item.BackColor.ToString(); if (!(bool)item.GetDataKeyValue("DOUTE_CLASSIFICATION")) { style = "myStyleWhite"; } else { style = "myStyleOrange"; } foreach (CellElement cellElement in e.Row.Cells) { cellElement.StyleValue = style; } } } } }