I have a Pivot grid and in Aggregate file i have placed the Textbox.
When user click on Save button i want to use looping to get all pivot grid item
In design
<telerik:PivotGridRowField DataField="SERVICName" Caption="SERVICName" CellStyle-Width="80px">
<celltemplate >
<asp:DropDownList ID="ddlService" runat="server" AutoPostBack="false">
</asp:DropDownList>
</celltemplate>
</telerik:PivotGridRowField>
<telerik:PivotGridRowField DataField="StartDate" Caption="StartDate" CellStyle-Width="80px">
</telerik:PivotGridRowField>
<telerik:PivotGridRowField DataField="EndDate" Caption="EndDate" CellStyle-Width="80px">
</telerik:PivotGridRowField>
<telerik:PivotGridAggregateField DataField="LoadHours" CellStyle-Width="60px">
<celltemplate >
<asp:TextBox ID='txtloadhours' runat="server" Width="46" Text='<%# Container.DataItem%>' ></asp:TextBox>
</celltemplate>
</telerik:PivotGridAggregateField>
Save Button Click :
for (int i = 0; i < RadPivotGrid1.Items.Count; i++)
{
}
here i want to get all the items of both Rowfield items and DataCell Items.
Guide me to get all the items from save button click.
When user click on Save button i want to use looping to get all pivot grid item
In design
<telerik:PivotGridRowField DataField="SERVICName" Caption="SERVICName" CellStyle-Width="80px">
<celltemplate >
<asp:DropDownList ID="ddlService" runat="server" AutoPostBack="false">
</asp:DropDownList>
</celltemplate>
</telerik:PivotGridRowField>
<telerik:PivotGridRowField DataField="StartDate" Caption="StartDate" CellStyle-Width="80px">
</telerik:PivotGridRowField>
<telerik:PivotGridRowField DataField="EndDate" Caption="EndDate" CellStyle-Width="80px">
</telerik:PivotGridRowField>
<telerik:PivotGridAggregateField DataField="LoadHours" CellStyle-Width="60px">
<celltemplate >
<asp:TextBox ID='txtloadhours' runat="server" Width="46" Text='<%# Container.DataItem%>' ></asp:TextBox>
</celltemplate>
</telerik:PivotGridAggregateField>
Save Button Click :
for (int i = 0; i < RadPivotGrid1.Items.Count; i++)
{
}
here i want to get all the items of both Rowfield items and DataCell Items.
Guide me to get all the items from save button click.
5 Answers, 1 is accepted
0
Hello Syed,
Can you please provide some more details about what you'd like to achieve? This way I will be able to provide more to the point information. Normally it would be easier for you to traverse the Items collection using foreach instead of for.
Looking forward to hearing from you
Regards,
Daniel
Telerik
Can you please provide some more details about what you'd like to achieve? This way I will be able to provide more to the point information. Normally it would be easier for you to traverse the Items collection using foreach instead of for.
foreach
(PivotGridItem item
in
RadPivotGrid1.Items)
{
...
}
Looking forward to hearing from you
Regards,
Daniel
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
0
Syed
Top achievements
Rank 1
answered on 13 Nov 2013, 11:39 PM
Hi,
Thanks for your replay,
Iam waiting for this reply for past two days,
In my Pivot grid AggregateFiled i have placed Textbox.
In text box i bind the LoadHours data .End user can change the hours and finaly need to save the data
And in my PivotgridRow field i have placed Combo box.
User can select value from combobox and need to save the data.
I have a Save Button.From my save button Click I want check each Item of Pivot Grid Aggregate Field Textbox.
If the Textbox value is greater then 0 then i want to save that textbox value and need to get the row values and column values of that Item cell.
In radgrid we have option for looping the grid and get all the cell value from the grid .
Same like that i need for the Pivotgrid to get all the row cell value using loop.
i have searched a lot but for pivot grid there is no example for the looping the grid.
so kindly give me some sample which has looping to get all the cell value of each row in pivot grid.
My pivotgrid design:
<telerik:PivotGridColumnField DataField="YDATE" Caption="YDATE" >
</telerik:PivotGridColumnField>
telerik:PivotGridRowField DataField="SERVICName" Caption="SERVICName" CellStyle-Width="80px">
<celltemplate >
<asp:DropDownList ID="ddlService" runat="server" AutoPostBack="false">
</asp:DropDownList>
</celltemplate>
</telerik:PivotGridRowField>
<telerik:PivotGridRowField DataField="StartDate" Caption="StartDate" CellStyle-Width="80px">
</telerik:PivotGridRowField>
<telerik:PivotGridRowField DataField="EndDate" Caption="EndDate" CellStyle-Width="80px">
</telerik:PivotGridRowField>
<telerik:PivotGridAggregateField DataField="LoadHours" CellStyle-Width="60px">
<celltemplate >
<asp:TextBox ID='txtloadhours' runat="server" Width="46" Text='<%# Container.DataItem%>' ></asp:TextBox>
</celltemplate>
</telerik:PivotGridAggregateField>
In Pivot grid cell data Bound we get the pivotgriddatacell value and each cell parent row and column values.is there any option in Save button click using loop to get the value.
for example in Pivot grid CellDataBound we use like this:
}
Same like this From Button click using pivotgrid looping i want to get all datacell value and its parent Row and Column Values
Thanks for your replay,
Iam waiting for this reply for past two days,
In my Pivot grid AggregateFiled i have placed Textbox.
In text box i bind the LoadHours data .End user can change the hours and finaly need to save the data
And in my PivotgridRow field i have placed Combo box.
User can select value from combobox and need to save the data.
I have a Save Button.From my save button Click I want check each Item of Pivot Grid Aggregate Field Textbox.
If the Textbox value is greater then 0 then i want to save that textbox value and need to get the row values and column values of that Item cell.
In radgrid we have option for looping the grid and get all the cell value from the grid .
Same like that i need for the Pivotgrid to get all the row cell value using loop.
i have searched a lot but for pivot grid there is no example for the looping the grid.
so kindly give me some sample which has looping to get all the cell value of each row in pivot grid.
My pivotgrid design:
<telerik:PivotGridColumnField DataField="YDATE" Caption="YDATE" >
</telerik:PivotGridColumnField>
telerik:PivotGridRowField DataField="SERVICName" Caption="SERVICName" CellStyle-Width="80px">
<celltemplate >
<asp:DropDownList ID="ddlService" runat="server" AutoPostBack="false">
</asp:DropDownList>
</celltemplate>
</telerik:PivotGridRowField>
<telerik:PivotGridRowField DataField="StartDate" Caption="StartDate" CellStyle-Width="80px">
</telerik:PivotGridRowField>
<telerik:PivotGridRowField DataField="EndDate" Caption="EndDate" CellStyle-Width="80px">
</telerik:PivotGridRowField>
<telerik:PivotGridAggregateField DataField="LoadHours" CellStyle-Width="60px">
<celltemplate >
<asp:TextBox ID='txtloadhours' runat="server" Width="46" Text='<%# Container.DataItem%>' ></asp:TextBox>
</celltemplate>
</telerik:PivotGridAggregateField>
In Pivot grid cell data Bound we get the pivotgriddatacell value and each cell parent row and column values.is there any option in Save button click using loop to get the value.
for example in Pivot grid CellDataBound we use like this:
if (e.Cell is PivotGridDataCell)
{
e.Cell.HorizontalAlign = HorizontalAlign.Right;
PivotGridDataCell cell = e.Cell as PivotGridDataCell;
if ((cell.Field as PivotGridAggregateField).DataField == "TotalHours")
{
string s = cell.ParentRowIndexes[0].ToString();
}
Same like this From Button click using pivotgrid looping i want to get all datacell value and its parent Row and Column Values
0
Hello Syed,
You can try something like this:
Regards,
Daniel
Telerik
You can try something like this:
protected
override
void
OnPreRender(EventArgs e)
{
base
.OnPreRender(e);
PivotGridDataCell dataCell;
foreach
(PivotGridItem item
in
RadPivotGrid1.Items)
foreach
(PivotGridCell cell
in
item.Cells)
{
dataCell = cell
as
PivotGridDataCell;
if
(dataCell !=
null
&& !dataCell.IsTotalCell && !dataCell.IsGrandTotalCell)
string
s = (dataCell.FindControl(
"txtloadhours"
)
as
TextBox).Text;
}
}
Regards,
Daniel
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
0
Syed
Top achievements
Rank 1
answered on 19 Nov 2013, 11:52 PM
Hi,
Thanks for your response,
I tried your code but i get error as "System.InvalidCastException: 'Telerik.Web.UI.PivotGridTableCell' " .
Here why we need to use prerender .AS i want to read all row cell value by some button click event.
Can you give me simple code to read all aggregate field cell data and its parent row and column field cell data by each row.
Thanks
Waiting for yourt early response.
Thanks for your response,
I tried your code but i get error as "System.InvalidCastException: 'Telerik.Web.UI.PivotGridTableCell' " .
Here why we need to use prerender .AS i want to read all row cell value by some button click event.
Can you give me simple code to read all aggregate field cell data and its parent row and column field cell data by each row.
Thanks
Waiting for yourt early response.
0
Hello Syed,
Please try modifying the following line:
Regards,
Daniel
Telerik
Please try modifying the following line:
foreach
(TableCell cell
in
item.Cells)
//TableCell instead of PivotGridCell
...
Regards,
Daniel
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
ahmed
commented on 03 Jul 2021, 01:15 AM
Top achievements
Rank 1
Hello Daniel, can u help me in this article .... https://www.telerik.com/forums/radpivotgrid-with-celltemplate-image