Drill down with drag and drop is not working

2 posts, 0 answers
  1. Rajshree
    Rajshree avatar
    36 posts
    Member since:
    Feb 2015

    Posted 18 Jun 2017 Link to this post

    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;
            }
     
        }
    }
  2. James
    James avatar
    2 posts
    Member since:
    Jan 2018

    Posted 16 Jan 2018 in reply to Rajshree Link to this post

    did you resolve this issue? i am having same problem.
Back to Top