Get all field in Filter Header Zone

10 posts, 0 answers
  1. karn
    karn avatar
    11 posts
    Member since:
    Feb 2010

    Posted 18 Mar 2015 Link to this post

    Hello,

    i try to get all field for my query and set into the filter header zone. 

    it is possible ?

    thanks !
  2. karn
    karn avatar
    11 posts
    Member since:
    Feb 2010

    Posted 23 Mar 2015 Link to this post

    Any idea ?

    i just want init the filter header zone, is not possible ?
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Angel Petrov
    Admin
    Angel Petrov avatar
    1006 posts

    Posted 23 Mar 2015 Link to this post

    Hello,

    I am not sure about the exact requirement but I suppose that you want to provide a value for the report filter field on initial load. If that is the case you can do something like this.

    C#:
    protected override void OnPreRender(EventArgs e)
    {
        base.OnPreRender(e);
        var reportFilterFields = RadPivotGrid1.Fields.GetFieldsByType("PivotGridReportFilterField");
        foreach (PivotGridReportFilterField field in reportFilterFields)
        {
            if (field.UniqueName == "SafetyLevel")
            {
                field.FilterType = PivotGridReportFilterActionType.Includes;
                field.FilterValues = new string[] { "200", "300" };
                field.FilterValueType = typeof(int);
            }
        }
        RadPivotGrid1.Rebind();
    }

    If the provided suggestion does not prove helpful please elaborate in detail on the exact functionality you want to implement so we could provide a straight to the point answer.

    Regards,
    Angel Petrov
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  5. karn
    karn avatar
    11 posts
    Member since:
    Feb 2010

    Posted 23 Mar 2015 in reply to Angel Petrov Link to this post

    hello,

    Thank for you reply, yes i want create a rad pivot grid and set the zone of report filter with all field of my datasource, i try this :

    protected override void OnPreRender(EventArgs e)
    {
     
        base.OnPreRender(e);
     
        DataView dview = (DataView)SqlDataSource1.Select(DataSourceSelectArguments.Empty);
        int i = 0;
        
        while (i < dview.Table.Columns.Count)           
        {
            PivotGridReportFilterField t = new PivotGridReportFilterField();
            t.DataField = dview.Table.Columns[i].ColumnName;
            t.UniqueName = dview.Table.Columns[i].ColumnName;
            pivotGrid.Fields.Add(t);             
            i++;
        }
        pivotGrid.Rebind();
    }

    it seems to work but when I move a field, I have this error seems logical: 
    "Duplicate unique names for RadPivotGrid's fields are not allowed."

    but I can not do this code in the init.

  6. karn
    karn avatar
    11 posts
    Member since:
    Feb 2010

    Posted 25 Mar 2015 Link to this post

    I redo a scratch test :
    Aspx :
    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="testd.aspx.cs" Inherits="testtab.testd" %>
    <%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
    <!DOCTYPE html>
     
    <head runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
        <title></title>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
            <telerik:RadScriptManager runat="server" ID="RadScriptManager1" />
            <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" DefaultLoadingPanelID="RadAjaxLoadingPanel1">
                <AjaxSettings>
                    <telerik:AjaxSetting AjaxControlID="PanelFieldsPopup">
                        <UpdatedControls>
                            <telerik:AjaxUpdatedControl ControlID="PanelFieldsPopup" />
                            <telerik:AjaxUpdatedControl ControlID="RadPivotGrid1" />
                        </UpdatedControls>
                    </telerik:AjaxSetting>
                    <telerik:AjaxSetting AjaxControlID="RadPivotGrid1">
                        <UpdatedControls>
                            <telerik:AjaxUpdatedControl ControlID="RadPivotGrid1" />
                        </UpdatedControls>
                    </telerik:AjaxSetting>
                </AjaxSettings>
            </telerik:RadAjaxManager>
            <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server">
            </telerik:RadAjaxLoadingPanel>
            <telerik:RadPivotGrid runat="server" ID="RadPivotGrid1"  Width="100%" >
                <FieldsPopupSettings RowFieldsMinCount="2" />
                
                <ClientSettings EnableFieldsDragDrop="true">
                    <ClientMessages DragToReorder="Drag the field to change its order"></ClientMessages>
                </ClientSettings>
            </telerik:RadPivotGrid>
            <asp:SqlDataSource ID="SqlDataSource1" ConnectionString="<%$ ConnectionStrings:cnx %>" SelectCommand="SELECT * FROM STUDIES" runat="server">
           </asp:SqlDataSource>          
        </div>
        </form>
    </body>
    </html>

    C# :
    using System;
    using System.Collections.Generic;
    using System.Data;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using Telerik.Web.UI;
     
    namespace testtab
    {
        public partial class testd : System.Web.UI.Page
        {
            protected void Page_Load(object sender, EventArgs e)
            {
                RadPivotGrid1.AllowPaging = true;
                RadPivotGrid1.EnableZoneContextMenu=true;
                RadPivotGrid1.AllowSorting=true;
                RadPivotGrid1.DataSourceID = "SqlDataSource1";
     
                DataView dview = (DataView)SqlDataSource1.Select(DataSourceSelectArguments.Empty);
     
                int i = 0;
                while (i < dview.Table.Columns.Count)
                {
     
                    PivotGridReportFilterField t = new PivotGridReportFilterField();
                    t.DataField = dview.Table.Columns[i].ColumnName;
                    t.FilterType = PivotGridReportFilterActionType.Includes;
                    t.UniqueName = dview.Table.Columns[i].ColumnName;
                    RadPivotGrid1.Fields.Add(t);
     
     
     
                    //PivotGridRowField rowField = new PivotGridRowField();      
                    //rowField.DataField = dview.Table.Columns[i].ColumnName;
                    //rowField.UniqueName = dview.Table.Columns[i].ColumnName;
                    //pivotGrid.Fields.Add(rowField);
                    i++;
                }
     
     
            }
        }
    }

    This seems to work but when I drag a field or click on filter , I have this error:
    "Sequence contains more than one matching element"
    Any idea ?


  7. Angel Petrov
    Admin
    Angel Petrov avatar
    1006 posts

    Posted 26 Mar 2015 Link to this post

    Hi,

    Please try modifying the code as demonstrated below and test the page again.

    C#:
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            RadPivotGrid1.AllowPaging = true;
            RadPivotGrid1.EnableZoneContextMenu = true;
            RadPivotGrid1.AllowSorting = true;
            RadPivotGrid1.DataSourceID = "SqlDataSource1";
     
            DataView dview = (DataView)SqlDataSource1.Select(DataSourceSelectArguments.Empty);
     
            int i = 0;
            while (i < dview.Table.Columns.Count)
            {
     
                PivotGridReportFilterField t = new PivotGridReportFilterField();
                RadPivotGrid1.Fields.Add(t);
                t.DataField = dview.Table.Columns[i].ColumnName;
                t.FilterType = PivotGridReportFilterActionType.Includes;
                t.UniqueName = dview.Table.Columns[i].ColumnName;
                i++;
            }
        }
    }

    The problem seems to be that the fields are added on each postback which is not correct. Information on how to add the pivot fields programmatically can be found here.

    Regards,
    Angel Petrov
    Telerik
     

    See What's Next in App Development. Register for TelerikNEXT.

     
  8. karn
    karn avatar
    11 posts
    Member since:
    Feb 2010

    Posted 26 Mar 2015 Link to this post

    Ok that work!

    I had a second bug, "RadPivotGrid1.Fields.Add (t);" must be place first.
    But I have one last problem... the ajax loader does not work, for every action I have a blank page during treatment and no the loader, i
    Aspx :
    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="result.aspx.cs" Inherits="testtab.result" %>
    <%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
    <!DOCTYPE html>
     
    <head runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
        <title></title>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
        <telerik:RadScriptManager ID="RadScriptManager1" runat="server" />   
        <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server">
        </telerik:RadAjaxLoadingPanel>
        <telerik:RadAjaxPanel ID="radAjaxPanel1" runat="server" LoadingPanelID="RadAjaxLoadingPanel1">
        <telerik:RadPivotGrid runat="server" ID="RadPivotGrid1"></telerik:RadPivotGrid>
        </telerik:RadAjaxPanel>
        </div>
            <asp:SqlDataSource ID="SqlDataSource1" ConnectionString="<%$ ConnectionStrings:cnx %>" SelectCommand="SELECT TOP 10000 * FROM CACHE_MOD_INDIC" runat="server">
           </asp:SqlDataSource
        </form>
    </body>
    </html>

    C# :
    using System;
    using System.Collections.Generic;
    using System.Configuration;
    using System.Data;
    using System.Data.SqlClient;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using Telerik.Web.UI;
     
     
    namespace testtab
    {
        public partial class result : System.Web.UI.Page
        {
    protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);
     
            RadPivotGrid1.NeedDataSource += new EventHandler<PivotGridNeedDataSourceEventArgs>(pivotGrid_NeedDataSource);
            //RadPivotGrid1.DataSourceID = "SqlDataSource1";
        }
     
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            if (!IsPostBack)
            {
                RadPivotGrid1.EmptyValue = "No data";
                RadPivotGrid1.ClientSettings.EnableFieldsDragDrop = true;
                RadPivotGrid1.AllowPaging = true;
                RadPivotGrid1.Width = new Unit(800);
                RadPivotGrid1.ColumnHeaderCellStyle.Width = new Unit(80);
                RadPivotGrid1.ClientSettings.Scrolling.AllowVerticalScroll = true;
     
                DataView dview = (DataView)SqlDataSource1.Select(DataSourceSelectArguments.Empty);
     
                int i = 0;
                while (i < dview.Table.Columns.Count)
                {
     
     
                        PivotGridReportFilterField t = new PivotGridReportFilterField();
                        RadPivotGrid1.Fields.Add(t);
                        t.DataField = dview.Table.Columns[i].ColumnName;
                        t.FilterType = PivotGridReportFilterActionType.Includes;
                        t.UniqueName = dview.Table.Columns[i].ColumnName;
     
                    i++;
                }
     
     
     
            }
        }
     
        void pivotGrid_NeedDataSource(object sender, PivotGridNeedDataSourceEventArgs e)
        {
            (sender as RadPivotGrid).DataSource = GetDataTable("SELECT TOP 10000 * FROM CACHE_MOD_INDIC");
        }
     
        public DataTable GetDataTable(string query)
        {
            String ConnString = ConfigurationManager.ConnectionStrings["cnx"].ConnectionString;
            SqlConnection conn = new SqlConnection(ConnString);
            SqlDataAdapter adapter = new SqlDataAdapter();
            adapter.SelectCommand = new SqlCommand(query, conn);
     
            DataTable myDataTable = new DataTable();
     
            conn.Open();
            try
            {
                adapter.Fill(myDataTable);
            }
            finally
            {
                conn.Close();
            }
     
            return myDataTable;
        }
    }
         
    }

    I do not understand why, I think I did the same thing as in Examples


  9. karn
    karn avatar
    11 posts
    Member since:
    Feb 2010

    Posted 30 Mar 2015 Link to this post

    Any idea for the problem of ajax ? I do different tests, but I still have the same problem (the loader is displayed, I have a white screen)
  10. Angel Petrov
    Admin
    Angel Petrov avatar
    1006 posts

    Posted 31 Mar 2015 Link to this post

    Hi,

    Please set provide a value for the Skin property of the RadAjaxLoadingPanel as demonstrated below and test the page again.

    ASPX:
    <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" Skin="Default" runat="server">
    </telerik:RadAjaxLoadingPanel>


    Regards,
    Angel Petrov
    Telerik
     

    See What's Next in App Development. Register for TelerikNEXT.

     
  11. karn
    karn avatar
    11 posts
    Member since:
    Feb 2010

    Posted 31 Mar 2015 in reply to Angel Petrov Link to this post

    That work ! Thank for you help !
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017