9 Answers, 1 is accepted
0

karn
Top achievements
Rank 1
answered on 23 Mar 2015, 08:44 AM
Any idea ?
i just want init the filter header zone, is not possible ?
i just want init the filter header zone, is not possible ?
0
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#:
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
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.
0

karn
Top achievements
Rank 1
answered on 23 Mar 2015, 03:32 PM
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 :
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.
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.
0

karn
Top achievements
Rank 1
answered on 25 Mar 2015, 04:14 PM
I redo a scratch test :
Aspx :
C# :
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 ?
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>
<
html
xmlns
=
"http://www.w3.org/1999/xhtml"
>
<
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 ?
0
Hi,
Please try modifying the code as demonstrated below and test the page again.
C#:
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
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.
0

karn
Top achievements
Rank 1
answered on 26 Mar 2015, 10:25 AM
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 :
C# :
I do not understand why, I think I did the same thing as in Examples
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>
<
html
xmlns
=
"http://www.w3.org/1999/xhtml"
>
<
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
0

karn
Top achievements
Rank 1
answered on 30 Mar 2015, 12:31 PM
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)
0
Hi,
Please set provide a value for the Skin property of the RadAjaxLoadingPanel as demonstrated below and test the page again.
ASPX:
Regards,
Angel Petrov
Telerik
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.
0

karn
Top achievements
Rank 1
answered on 31 Mar 2015, 07:27 AM
That work ! Thank for you help !