Hi. I'm trying to export data to Excel using BIFF with Telerik version 2016.3.1027.40-. The data that needs to be included in the spreadsheet is in a detail table with paging. My code successfully exports data only on the first page displayed on the UI. I've implemented the suggestion here https://docs.telerik.com/devtools/aspnet-ajax/controls/grid/functionality/exporting/overview#ignorepaging-not-working-on-detailtables-excel-export to disable paging but it didn't work in my case. Can someone tell me how I can achieve this functionality given this as my view code
<telerik:Radgrid Rendermode="Lightweight" ID="RadGrid1" runat="server" showstatusbar="true" autogeneratecolumns="False" AllowFilteringByColumn="True" pagesize="10" allowsorting="True" allowmultirowselection="False" allowpaging="True" Filtertype="Combined" onneeddatasource="RadGrid1_NeedDataSource" oniteminserted="RadGrid1_ItemInserted" onitemcommand="RadGrid1_ItemCommand" oninsertcommand="RadGrid1_InsertCommand" onupdatecommand="RadGrid1_UpdateCommand" onitemdatabound="RadGrid1_ItemDataBound" ondetailtabledatabind="RadGrid1_DetailTableDataBind" OnDeleteCommand="RadGrid1_DeleteCommand" Skin="Outlook" OnItemCreated="RadGrid1_ItemCreated" ShowExportToExcelButton="true" onBiffExporting="RadGrid1_BiffExporting"> <MasterTableView AutoGenerateColumns="False" UniqueName="CATDESCRIPTION" AllowMultiColumnSorting="True" DataKeyNames="CAT_DESCRIPTION" PagerStyle-AlwaysVisible="true" EditMode="InPlace" CommandItemDisplay="Top"> <DetailTables> <telerik:GridTableView DataKeyNames="pk" Name="Codes" TableLayout="Auto" EditMode="InPlace" PagerStyle-AlwaysVisible="true" CommandItemDisplay="Top"> <CommandItemSettings ShowExportToExcelButton="true" /> <CommandItemSettings AddNewRecordText="Add Rule" />Additional code omitted...
and this is part of the code-behind:
protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e) { if (e.CommandName.Equals(Telerik.Web.UI.RadGrid.ExportToExcelCommandName)) { RadGrid1.ExportSettings.Excel.Format = GridExcelExportFormat.Biff; RadGrid1.ExportSettings.FileName = "Output"; RadGrid1.ExportSettings.ExportOnlyData = true; RadGrid1.ExportSettings.OpenInNewWindow = true; //disable paging on the main grid for the export operation RadGrid1.ExportSettings.IgnorePaging = false; //expand detail tables RadGrid1.MasterTableView.HierarchyDefaultExpanded = true; RadGrid1.MasterTableView.DetailTables[0].HierarchyDefaultExpanded = true; foreach (GridTableView tbl in RadGrid1.MasterTableView.DetailTables) { tbl.HierarchyDefaultExpanded = true; //disable paging for the detail grids for the export operation tbl.AllowPaging = false; } }}Hello,
I have a graph containing several "LinesSeries". Each "LinesSeries" contains several points on the X axis but always the same value on Y (different value between the series)
I would like to know if it is possible to display the label of each serie only once and on the first point of each series.
thank you
Hello, I am looking at this product to see if it can meet my needs. What I have is an asp.net web form with C# code behind with 5 asp.net grid views on the page. I have a lot of jquery and css customization including custom colors for the grid rows that I need an ability on an asp:button press event convert my grid to a pdf with the custom row colors.
Is this something your product can handle? Do you have demo tutorial on how to do such? I have looked but have not found it.
| <MasterTableView> |
| <Columns> |
| <telerik:GridBoundColumn UniqueName="Description" DataField="Description" HtmlEncode="true" /> |
| </Columns> |
| </MasterTableView> |
| <ClientSettings> |
| <DataBinding Location="WebService.asmx" SelectMethod="GetData" /> |
| </ClientSettings> |
I'm using the telerik:RadSearchBox and have it connected to a datasource/web service with autocomplete enabled.
This datasource is connect to database table that has over 1 million records. On a page load or page preinit, the web page will timeout due to the large amount of data its trying to load.
What is the best method for the telerik:RadSearchBox to connect to the datasource and populate the autocomplete feature with a large dataset?
Thanks in advance.
Kevin

I need to use drill down with drag and drop and integration with chart. i have used the samples to use drill down functionality. however, when i try to drag and drop one of the filterfield to row/column field. it shows the error to get correct count of rowfileld or columnfield. i tried to move code from on init to other places but it gives the error either way.
can you please help on this?
<style> .breadcrumb { padding: 4px 10px !important; margin-bottom: 10px !important; list-style: none; background-color: #f5f5f5; border-radius: 4px;}</style> <telerik:RadCodeBlock runat="server"> <style type="text/css"> .rpgContentZone th[onclick], .rpgContentZone td[onclick] { cursor: pointer; } </style> <script type="text/javascript"> function OpenDetailsWindow(argument) { $find("<%= RadAjaxPanel1.ClientID %>").ajaxRequest(argument); } </script> </telerik:RadCodeBlock><div> <!--start of breadcrumb--> <ol class="breadcrumb container"> <li class="active">Incident Navigator</li> <li class="active">Trending</li> </ol> <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server"> </telerik:RadAjaxLoadingPanel> <telerik:RadAjaxManagerProxy ID="AjaxManagerProxy1" runat="server"> <AjaxSettings> <telerik:AjaxSetting AjaxControlID="RadPivotGrid1"> <UpdatedControls> <telerik:AjaxUpdatedControl ControlID="RadPivotGrid1" LoadingPanelID="RadAjaxLoadingPanel1" /> <telerik:AjaxUpdatedControl ControlID="RadHtmlChart1" LoadingPanelID="RadAjaxLoadingPanel1" /> </UpdatedControls> </telerik:AjaxSetting> <telerik:AjaxSetting AjaxControlID="rdComboTicketType"> <UpdatedControls> <telerik:AjaxUpdatedControl ControlID="RadPivotGrid1" LoadingPanelID="RadAjaxLoadingPanel1" /> <telerik:AjaxUpdatedControl ControlID="RadHtmlChart1" LoadingPanelID="RadAjaxLoadingPanel1" /> </UpdatedControls> </telerik:AjaxSetting> </AjaxSettings> </telerik:RadAjaxManagerProxy> <div class="container" style="padding: 0;"> <div style="vertical-align:top;text-align:center;"> <telerik:RadLabel runat="server" ID="lblReport" CssClass="reportlbl"> </telerik:RadLabel> </div> <telerik:RadHtmlChart ID="RadHtmlChart1" Height="350px" runat="server" Visible="true" Legend-Appearance-Position="Bottom" PlotArea-XAxis-LabelsAppearance-RotationAngle="45" PlotArea-YAxis-MinValue="0" PlotArea-YAxis-Type="Numeric"> <%-- <ChartTitle > <Appearance Align="Center" BackgroundColor="Transparent" Position="Top"> <TextStyle FontSize="13" FontFamily="Helvetica Neue, Helvetica, Arial, sans-serif;" Bold="true" /> </Appearance> </ChartTitle> --%> </telerik:RadHtmlChart> <br /> <telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server" EnableAJAX="true" OnAjaxRequest="RadAjaxPanel1_AjaxRequest" LoadingPanelID="RadAjaxLoadingPanel1"> <telerik:RadPivotGrid RenderMode="Lightweight" runat="server" ID="RadPivotGrid1" AllowPaging="false" OnCellDataBound="RadPivotGrid1_CellDataBound" OnNeedDataSource="RadPivotGrid1_NeedDataSource" OnDataBinding="RadPivotGrid1_DataBinding" OnItemCommand="RadPivotGrid1_ItemCommand" AllowSorting="true" AllowFiltering="true" ShowFilterHeaderZone="true" EnableZoneContextMenu="true" > <%-- <PagerStyle Mode="NextPrevNumericAndAdvanced" AlwaysVisible="true"></PagerStyle>--%> <DataCellStyle Width="50px" /> <Fields> <telerik:PivotGridColumnField DataField="Year"> </telerik:PivotGridColumnField> <telerik:PivotGridReportFilterField DataField="Quarter" > </telerik:PivotGridReportFilterField> <telerik:PivotGridReportFilterField DataField="AffectedItemName" Caption="Application" > </telerik:PivotGridReportFilterField> <telerik:PivotGridReportFilterField DataField="WorkgroupName" Caption="Assignment group" > </telerik:PivotGridReportFilterField> <telerik:PivotGridReportFilterField DataField="Level" Caption="Service Level" > </telerik:PivotGridReportFilterField> <telerik:PivotGridReportFilterField DataField="Severity" > </telerik:PivotGridReportFilterField> <telerik:PivotGridColumnField DataField="MonthName" SortOrder="None" > </telerik:PivotGridColumnField> <telerik:PivotGridRowField DataField="CauseCategoryName"> </telerik:PivotGridRowField> <%-- <telerik:PivotGridRowField DataField="City"> </telerik:PivotGridRowField>--%> <telerik:PivotGridAggregateField DataField="IncidentId" Aggregate="Count" SortOrder="Ascending" > </telerik:PivotGridAggregateField> </Fields> <ClientSettings EnableFieldsDragDrop="true"> <%--<Scrolling AllowVerticalScroll="true"></Scrolling>--%> <ClientMessages DragToReorder="Drag the field to change its order"></ClientMessages> </ClientSettings> </telerik:RadPivotGrid> <telerik:RadWindow ID="RadWindow1" runat="server" MinWidth="900px" MinHeight="450px"> <ContentTemplate> <telerik:RadAjaxLoadingPanel runat="server" ID="RadAjaxLoadingPanel2" Skin="Default"></telerik:RadAjaxLoadingPanel> <telerik:RadAjaxPanel ID="RadAjaxPanel2" runat="server" LoadingPanelID="RadAjaxLoadingPanel2"> <telerik:RadGrid runat="server" ID="RadGrid1" AllowSorting="true" PageSize="5" OnNeedDataSource="RadGrid1_NeedDataSource" AllowPaging="true"> </telerik:RadGrid> </telerik:RadAjaxPanel> </ContentTemplate> </telerik:RadWindow> </telerik:RadAjaxPanel> </div> <style type="text/css"> .PivotGridWindow { width: 700px !important; height: 400px !important; } .reportlbl{ font-size:small; font-family:Helvetica Neue, Helvetica, Arial, sans-serif; font-weight:bold; } </style> </div> ------------------------------- public partial class TrendingControl : System.Web.UI.UserControl { List<PivotGridField> rowFields; List<PivotGridField> columnFields; List<PivotGridField> aggregateFields; int index = 0; int[] allFakeColumnCells = null; bool isFirstDataCell = true; int countOfFakeRowCells = 0; int cellsCount = 0; string firstRowID = string.Empty; string currentRowID = string.Empty; int key = 0; public int? AffectedItemId { get { if (((MasterPage)Page.Master).AppId != null) { return ((MasterPage)Page.Master).AppId; } else { return null; } } } public List<string> TicketTypelist { get { if (((MasterPage)Page.Master).TicketTypelist != null) { return ((MasterPage)Page.Master).TicketTypelist; } else { return null; } } } public Dictionary<int, string> Arguments { get { if (Session["Arguments"] == null) { Session["Arguments"] = new Dictionary<int, string>(); } return Session["Arguments"] as Dictionary<int, string>; } set { Session["Arguments"] = value; } } public DataTable GridDataSource { get { return Session["GridDataSource"] as DataTable; } set { Session["GridDataSource"] = value; } } public List<INAffectedItem> listAffectedItemlist { get { var list = new List<INAffectedItem>(); using (var db = new Entities()) { list = db.INAffectedItems.ToList(); } return list; } } HashSet<string> columnNames = new HashSet<string>(); Dictionary<string, LineSeries> LineSeriesByRowName = new Dictionary<string, LineSeries>(); protected override void OnPreRender(EventArgs e) { base.OnPreRender(e); if (!Page.IsPostBack) { if (AffectedItemId == 0) { using (var db = new Entities()) { var v = db.IN_Trending_dS(string.Join(",", TicketTypelist)); string year = v.Max(x => x.Year).GetValueOrDefault().ToString(); RadPivotGrid1.FilterByLabel(PivotGridFilterFunction.Equals, RadPivotGrid1.Fields["Year"], year); //RadPivotGrid1.FilterByValue(PivotGridFilterFunction.Top, RadPivotGrid1.Fields["AffectedItemName"], RadPivotGrid1.Fields["IncidentId"] as PivotGridAggregateField, "5"); } } else { using (var db = new Entities()) { var v = db.IN_TrendingByAffectedItem_dS(AffectedItemId.Value, string.Join(",", TicketTypelist)); var year = v.Max(x => x.Year).GetValueOrDefault().ToString(); RadPivotGrid1.FilterByLabel(PivotGridFilterFunction.Contains, RadPivotGrid1.Fields["Year"], year); } } } //for (int i = 0; i < RadPivotGrid1.Fields.Count; i++) //{ // RadPivotGrid1.Fields[i].Caption = (i + 1).ToString(); //} RadPivotGrid1.Fields["CauseCategoryName"].Caption = ClosureCategoryName; //RadPivotGrid1.ColumnGroupsDefaultExpanded = false; //RadPivotGrid1.RowGroupsDefaultExpanded = false; columnNames = new HashSet<string>(); LineSeriesByRowName = new Dictionary<string, LineSeries>(); RadPivotGrid1.Rebind(); // rowFields = RadPivotGrid1.Fields.Where(f => //f is PivotGridRowField && f.IsHidden == false).OrderBy(f => f.ZoneIndex).ToList(); // columnFields = RadPivotGrid1.Fields.Where(f => // f is PivotGridColumnField && f.IsHidden == false).OrderBy(f => f.ZoneIndex).ToList(); // aggregateFields = RadPivotGrid1.Fields.Where(f => // f is PivotGridAggregateField && f.IsHidden == false).OrderBy(f => f.ZoneIndex).ToList(); } protected override void OnInit(EventArgs e) { base.OnInit(e); rowFields = RadPivotGrid1.Fields.Where(f => f is PivotGridRowField && f.IsHidden == false).OrderBy(f => f.ZoneIndex).ToList(); columnFields = RadPivotGrid1.Fields.Where(f => f is PivotGridColumnField && f.IsHidden == false).OrderBy(f => f.ZoneIndex).ToList(); aggregateFields = RadPivotGrid1.Fields.Where(f => f is PivotGridAggregateField && f.IsHidden == false).OrderBy(f => f.ZoneIndex).ToList(); } protected void Page_Load(object sender, EventArgs e) { if (AffectedItemId == 0) { lblReport.Text = "Monthly Incidents by " + ClosureCategoryName + " for All Applications"; } else { var v = listAffectedItemlist.Where(x => x.Id == AffectedItemId.Value).FirstOrDefault(); lblReport.Text = "Monthly Incidents by " + ClosureCategoryName + " for " + v.AffectedItemName; } //this.RadHtmlChart1.PlotArea.XAxis.Items.Clear(); //this.RadHtmlChart1.PlotArea.Series.Clear(); // RadPivotGrid1.Rebind(); } public static DataTable ToDataTable<T>(List<T> items) { DataTable dataTable = new DataTable(typeof(T).Name); //Get all the properties PropertyInfo[] Props = typeof(T).GetProperties(BindingFlags.Public | BindingFlags.Instance); foreach (PropertyInfo prop in Props) { //Defining type of data column gives proper data table var type = (prop.PropertyType.IsGenericType && prop.PropertyType.GetGenericTypeDefinition() == typeof(Nullable<>) ? Nullable.GetUnderlyingType(prop.PropertyType) : prop.PropertyType); //Setting column names as Property names dataTable.Columns.Add(prop.Name, type); } foreach (T item in items) { var values = new object[Props.Length]; for (int i = 0; i < Props.Length; i++) { //inserting property values to datatable rows values[i] = Props[i].GetValue(item, null); } dataTable.Rows.Add(values); } //put a breakpoint here and check datatable return dataTable; } protected void RadPivotGrid1_NeedDataSource(object sender, Telerik.Web.UI.PivotGridNeedDataSourceEventArgs e) { if (AffectedItemId == 0) { using (var db = new Entities()) { var v = db.IN_Trending_dS(string.Join(",", TicketTypelist)); (sender as RadPivotGrid).DataSource = ToDataTable(v.OrderBy(x => x.Year).ThenBy(x => x.Month).ToList()); } } else { using (var db = new Entities()) { var v = db.IN_TrendingByAffectedItem_dS(AffectedItemId.Value, string.Join(",", TicketTypelist)); if (v != null) { var selectedAppsource = v.OrderBy(x => x.Year).ThenBy(x => x.Month).ToList(); (sender as RadPivotGrid).DataSource = ToDataTable(selectedAppsource); } } } } protected void RadPivotGrid1_CellDataBound(object sender, PivotGridCellDataBoundEventArgs e) { PivotGridDataCell cell = e.Cell as PivotGridDataCell; if (cell != null) { // If this is the first data cell we need to populate the collecion which fake columns cells count if (isFirstDataCell) { PopulateFakeColumnsCellCollection(cell); isFirstDataCell = false; } // We do not need to attach onclick event on cell which does not have values if (cell.DataItem != null) { string argument = GetCommandArguments(cell); string script = string.Format("OpenDetailsWindow('{0}')", argument); cell.Attributes.Add("onclick", script); } index++; } PivotGridDataCell dataCell = e.Cell as PivotGridDataCell; if (columnNames.Count == 0) { this.RadHtmlChart1.PlotArea.XAxis.Items.Clear(); this.RadHtmlChart1.PlotArea.Series.Clear(); //if (AffectedItemId == 0) //{ // this.RadHtmlChart1.ChartTitle.Text = "Monthly Incidents by Closure Category for All Applications"; //} //else //{ // var v = listIncidentlist.Where(x => x.AffectedItemId == AffectedItemId.Value).FirstOrDefault(); // this.RadHtmlChart1.ChartTitle.Text = "Monthly Incidents by Closure Category for " + v.AffectedItemName; //} } if (dataCell != null && dataCell.CellType == PivotGridDataCellType.DataCell) { string rowName = GetName(dataCell.ParentRowIndexes); //if(dataCell.ParentColumnIndexes[1]!= null) //{ // int month = 0; // if (int.TryParse(dataCell.ParentColumnIndexes[1].ToString(), out month)) // { // dataCell.ParentColumnIndexes[1]= CultureInfo.CurrentCulture.DateTimeFormat.GetAbbreviatedMonthName(int.Parse(dataCell.ParentColumnIndexes[1].ToString())); // } //} string columnName = GetName(dataCell.ParentColumnIndexes); columnName = columnName.Replace('\'', ' '); if (columnNames.Add(columnName)) { AxisItem axisItem = new AxisItem(columnName); this.RadHtmlChart1.PlotArea.XAxis.Items.Add(axisItem); } LineSeries lineSeries = null; if (LineSeriesByRowName.ContainsKey(rowName)) { lineSeries = LineSeriesByRowName[rowName]; } else { lineSeries = new LineSeries(); LineSeriesByRowName.Add(rowName, lineSeries); lineSeries.Name = rowName; // columnSeries.LabelsAppearance.DataFormatString = "C"; this.RadHtmlChart1.PlotArea.Series.Add(lineSeries); } lineSeries.LabelsAppearance.Visible = false; CategorySeriesItem item = new CategorySeriesItem(); int value = 0; if (e.Cell.DataItem != null && int.TryParse(e.Cell.DataItem.ToString(), out value)) { item.Y = value; } else { item.Y = null; } lineSeries.SeriesItems.Add(item); } } // This methos is executed only for the first cell from the first row private void PopulateFakeColumnsCellCollection(PivotGridDataCell cell) { PivotGridDataItem item = cell.NamingContainer as PivotGridDataItem; cellsCount = item.Cells.Count; allFakeColumnCells = new int[cellsCount]; firstRowID = item.UniqueID; for (int i = 0; i < cellsCount; i++) { int countOfFakeCells = GetCountOfFakeColumnCells(item.Cells[i] as PivotGridDataCell); allFakeColumnCells[i] = countOfFakeCells; } } private string GetName(object[] indexes) { StringBuilder builder = new StringBuilder(); foreach (object index in indexes) { builder.Append(index.ToString()); builder.Append("/"); } builder.Remove(builder.Length - 1, 1); return builder.ToString(); } protected void RadPivotGrid1_DataBinding(object sender, EventArgs e) { Arguments.Clear(); } protected void RadPivotGrid1_ItemCommand(object sender, PivotGridCommandEventArgs e) { RadWindow1.VisibleOnPageLoad = false; } protected void RadAjaxPanel1_AjaxRequest(object sender, AjaxRequestEventArgs e) { StringBuilder whereClause = new StringBuilder(); if (!string.IsNullOrEmpty(e.Argument.ToString())) { string[] elements = e.Argument.ToString().Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries); foreach (var element in elements) { var group = element.Split(new char[] { '~' }, StringSplitOptions.RemoveEmptyEntries); int firstPart = Convert.ToInt32(group[0]); int secondPart = Convert.ToInt32(group[1]); whereClause.Append(string.Format("{0} = '{1}' AND ", Arguments[firstPart], Arguments[secondPart])); } // Remove the last " AND " clause whereClause.Remove(whereClause.Length - 5, 5); GridDataSource = GetTable(); //GridDataSource = GetDataTable(string.Format("SELECT * FROM Transportation WHERE {0}", whereClause.ToString())); } //Executed when row and column grandtotal cell is clicked else { GridDataSource = GetTable(); } RadWindow1.VisibleOnPageLoad = true; RadGrid1.Rebind(); } static DataTable GetTable() { // Here we create a DataTable with four columns. DataTable table = new DataTable(); table.Columns.Add("Dosage", typeof(int)); table.Columns.Add("Drug", typeof(string)); table.Columns.Add("Patient", typeof(string)); table.Columns.Add("Date", typeof(DateTime)); // Here we add five DataRows. table.Rows.Add(25, "Indocin", "David", DateTime.Now); table.Rows.Add(50, "Enebrel", "Sam", DateTime.Now); table.Rows.Add(10, "Hydralazine", "Christoff", DateTime.Now); table.Rows.Add(21, "Combivent", "Janet", DateTime.Now); table.Rows.Add(100, "Dilantin", "Melanie", DateTime.Now); return table; } public string GetCommandArguments(PivotGridDataCell cell) { // True when first cell of each row is hit if (currentRowID != cell.NamingContainer.UniqueID) { index = 0; currentRowID = cell.NamingContainer.UniqueID; countOfFakeRowCells = GetCountOfFakeRowCells(cell); } object[] rowIndexes = cell.ParentRowIndexes; object[] columnIndexes = cell.ParentColumnIndexes; int rowIndexesCount = rowIndexes.Count(); int columnIndexesCount = columnIndexes.Count(); int countOfFakeColumnCells = allFakeColumnCells[index]; rowIndexesCount -= countOfFakeRowCells; columnIndexesCount -= countOfFakeColumnCells; StringBuilder buider = BuildArguments(rowIndexes, columnIndexes, rowIndexesCount, columnIndexesCount); return buider.ToString(); } private StringBuilder BuildArguments(object[] rowIndexes, object[] columnIndexes, int rowIndexesCount, int columnIndexesCount) { StringBuilder buider = new StringBuilder(); ReplaceArgumentsWithNumbers(rowIndexes, rowFields, rowIndexesCount, buider); ReplaceArgumentsWithNumbers(columnIndexes, columnFields, columnIndexesCount, buider); // Remove the semicolon in the end if (buider.Length > 1) { buider.Remove(buider.Length - 1, 1); } return buider; } private void ReplaceArgumentsWithNumbers(object[] cellIndexes, List<PivotGridField> fields, int indexesCount, StringBuilder buider) { for (int i = 0; i < indexesCount; i++) { string firstPart = fields[i].DataField; string secondPart = cellIndexes[i].ToString(); if (Arguments.ContainsValue(firstPart)) { buider.Append(Arguments.FirstOrDefault(a => a.Value == firstPart).Key); AppendSecondParts(buider, secondPart); } else { Arguments.Add(key, firstPart); buider.Append(string.Format("{0}", key.ToString())); key++; AppendSecondParts(buider, secondPart); } } } private void AppendSecondParts(StringBuilder buider, string secondPart) { if (Arguments.ContainsValue(secondPart)) { buider.Append(string.Format("~{0};", Arguments.FirstOrDefault(a => a.Value == secondPart).Key)); } else { Arguments.Add(key, secondPart); buider.Append(string.Format("~{0};", key.ToString())); key++; } } private int GetCountOfFakeColumnCells(PivotGridDataCell cell) { int count = 0; if (aggregateFields.Count > 1) { if (RadPivotGrid1.AggregatesPosition == PivotGridAxis.Columns) { if (cell.CellType == PivotGridDataCellType.DataCell || cell.CellType == PivotGridDataCellType.RowTotalDataCell || cell.CellType == PivotGridDataCellType.RowAndColumnTotal || cell.CellType == PivotGridDataCellType.RowGrandTotalDataCell || cell.CellType == PivotGridDataCellType.ColumnGrandTotalRowTotal) { count++; } } } // if column total or grand total cell is hit we need to escape its values from query if (cell.CellType == PivotGridDataCellType.ColumnTotalDataCell || cell.CellType == PivotGridDataCellType.RowAndColumnTotal || cell.CellType == PivotGridDataCellType.ColumnGrandTotalRowTotal || cell.CellType == PivotGridDataCellType.ColumnGrandTotalDataCell || cell.CellType == PivotGridDataCellType.RowGrandTotalColumnTotal) { count++; } return count; } private int GetCountOfFakeRowCells(PivotGridDataCell cell) { int count = 0; //if aggregates are more than one additional cells are rendered, so we need to exclude their values from the query if (aggregateFields.Count > 1) { if (RadPivotGrid1.AggregatesPosition == PivotGridAxis.Rows) { if (cell.CellType != PivotGridDataCellType.RowTotalDataCell && cell.CellType != PivotGridDataCellType.ColumnGrandTotalRowTotal) { count++; } } } // if row total or grand total cell is hit we need to escape its values from query if (cell.CellType == PivotGridDataCellType.RowTotalDataCell || cell.CellType == PivotGridDataCellType.ColumnGrandTotalRowTotal || cell.CellType == PivotGridDataCellType.RowGrandTotalDataCell) { count++; } return count; } protected void RadGrid1_NeedDataSource(object sender, GridNeedDataSourceEventArgs e) { RadGrid1.DataSource = GridDataSource; } }}Hello,
for our website i've built some functionality into our basepage that creates a commandrow with a 'ClearAllFilters' button for every grid.
At first glance this seems to work fine. However, when selecting an item in a grid after a postback (for example filtering, or paging) it is selecting not from the filtered source, but the unfiltered source. So visually the grid is filtered, but when selecting an item it is using the complete list.
Somehow i have the feeling that the adding of a handler for the itemcommand is overwriting certain functionality that is otherwise called during the itemcommand event. However i have not been able to fix the problem, and ive tried tons of things.
Please have a look at the code and let me know if i am doing something wrong here!
Public Class BasePage Inherits Page Private ReadOnly Property AllowedFilterItems As String() = New String() {"Contains", "StartsWith", "EqualTo", "NotEqualTo"} Protected Overrides Sub OnInit(e As EventArgs) For Each grid As RadGrid In Controls.All().OfType(Of RadGrid)() DefineGridStructure(grid) Next MyBase.OnInit(e) End Sub Private Sub DefineGridStructure(grid As RadGrid) AddHandler grid.Load, New EventHandler(AddressOf Grid_OnLoad) AddHandler grid.ItemCommand, New GridCommandEventHandler(AddressOf Grid_OnCommand) AddHandler grid.PreRender, New EventHandler(AddressOf Grid_OnPreRender) AddCommandRow(grid) End Sub Protected Sub BasePage_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load SetupRadgridPaging() End Sub#Region "Radgrid event handlers and helper functions" Public Sub SetupRadgridPaging() For Each grid As RadGrid In Controls.All().OfType(Of RadGrid)() If grid.MasterTableView.DetailTables.Count = 0 AndAlso (grid.AllowPaging OrElse grid.MasterTableView.AllowPaging) Then AddHandler grid.PageSizeChanged, AddressOf Grid_OnPageSizeChanged Dim pageSize = GetPagerSizeForUser(GetGridPagerSettingsKey(grid.ID)) UpdateNewPageSize = False grid.PageSize = pageSize grid.PagerStyle.AlwaysVisible = True grid.AllowPaging = False grid.MasterTableView.PageSize = pageSize grid.MasterTableView.PagerStyle.AlwaysVisible = True grid.MasterTableView.AllowPaging = True UpdateNewPageSize = True End If Next End Sub Private Sub Grid_OnCommand(sender As Object, e As GridCommandEventArgs) Dim grid As RadGrid = CType(sender, RadGrid) If e.CommandName.Equals("ClearAllFilters", StringComparison.InvariantCultureIgnoreCase) Then For Each column As GridColumn In grid.Columns column.CurrentFilterFunction = GridKnownFunction.NoFilter column.CurrentFilterValue = String.Empty Next grid.MasterTableView.FilterExpression = String.Empty grid.Rebind() End If End Sub Private Sub Grid_OnLoad(sender As Object, e As EventArgs) Dim grid As RadGrid = CType(sender, RadGrid) ConfigureFilterMenu(grid) End Sub Private Sub Grid_OnPreRender(sender As Object, e As EventArgs) Dim grid As RadGrid = CType(sender, RadGrid) SetCommandItemVisibility(grid) End Sub Private Sub SetCommandItemVisibility(grid As RadGrid) Dim hasFilter As Boolean = False For Each column As GridColumn In grid.Columns If Not column.CurrentFilterValue = String.Empty Then hasFilter = True Exit For End If Next grid.MasterTableView.CommandItemDisplay = If(hasFilter, GridCommandItemDisplay.Top, GridCommandItemDisplay.None) grid.Rebind() End Sub Private Sub AddCommandRow(grid As RadGrid) grid.MasterTableView.CommandItemTemplate = New GridCommandItemTemplate(CType(LocalizationManager, LocalizationManager)) End Sub Private Sub ConfigureFilterMenu(grid As RadGrid) grid.FilterMenu.Items().ToList().ForEach(Sub(fi) grid.FilterMenu.Items.Remove(fi)) AllowedFilterItems.ForEach(Sub(fi) grid.FilterMenu.Items.Add(New RadMenuItem(fi) With {.Value = fi})) grid.FilterMenu.Localize(App.Session.CurrentCultureIdentifier) End Sub Public Sub Grid_OnPageSizeChanged(sender As Object, e As GridPageSizeChangedEventArgs) Dim grid As RadGrid = CType(sender, RadGrid) UpdateUserSetting(GetGridPagerSettingsKey(grid.ID), e.NewPageSize.ToString()) End Sub Public Function GetGridPagerSettingsKey(grid As String) As String Const prefix As String = "CPGridPager" Dim sPath As String = Request.Url.AbsolutePath Dim oInfo As New FileInfo(sPath) Dim pageName As String = Path.GetFileNameWithoutExtension(oInfo.Name) Return String.Concat(prefix, separator, pageName, separator, grid) End Function#Region "GridCommandItemTemplate" Private Class GridCommandItemTemplate Implements ITemplate Private clearFilter As ImageButton Private _localizationManager As LocalizationManager Public Sub New(ByRef localizationManager As LocalizationManager) MyBase.New _localizationManager = localizationManager End Sub Public Sub InstantiateIn(container As Control) Implements ITemplate.InstantiateIn clearFilter = New ImageButton With { .ID = "clearFilter", .ToolTip = _localizationManager.Localize("Grid_ClearFilters", App.Session.CurrentCultureIdentifier), .CommandName = "ClearAllFilters", .ImageUrl = "/Images/Grid/ClearFilter.png" } container.Controls.Add(clearFilter) End Sub End Class#End Region#End Region| <telerik:RadScriptManager ID="RadScriptManager1" runat="server"> |
| <Scripts> |
| <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" /> |
| </Scripts> |
| </telerik:RadScriptManager> |
| <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server"> |
| <ajaxsettings> |
| <telerik:AjaxSetting AjaxControlID="RadGridGroups"> |
| <UpdatedControls> |
| <telerik:AjaxUpdatedControl ControlID="RadGridGroups" /> |
| </UpdatedControls> |
| </telerik:AjaxSetting> |
| </ajaxsettings> |
| </telerik:RadAjaxManager> |
| <strong>Groups:</strong> |
| <telerik:RadGrid ID="RadGridGroups" runat="server" AllowPaging="true" |
| PageSize="5" GridLines="None" width="95%"> |
| <clientsettings allowkeyboardnavigation="true" enablepostbackonrowclick="true"> |
| <Selecting AllowRowSelect="true" /> |
| </clientsettings> |
| <mastertableview datakeynames="Group_ID" /> |
| <pagerstyle mode="NextPrevAndNumeric" /> |
| </telerik:RadGrid> |
