Articles in this section
Category / Section

How to find default control template for value cells when a pivot grid has value editing enabled

1 min read

PivotGrid control uses the PivotGridTemplateCell as a cell template for both editing cell and normal (non-editable) cell. The only difference here is, for editing mode the cell type is textbox and for normal mode the cell type is static.

 

XAML

<Window.Resources>
<!--Used for Cell Editing Template-->
<DataTemplate x:Key="Textboxtemplate">
<TextBox
Height ="24"
Width="{Binding Width,RelativeSource={RelativeSource TemplatedParent}}"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
Text="{Binding CellBoundValue}"
ToolTip="{Binding CellBoundValue}" />
</DataTemplate>
<!--Used for Cell Item Template-->
<DataTemplate x:Key="TextTemplate">
<TextBlock Text="{Binding CellBoundValue}" ToolTip="{Binding CellBoundValue}" />
</DataTemplate>
</Window.Resources>
 

 

C#

void InternalGrid_QueryCellInfo(object sender, Syncfusion.Windows.Controls.Grid.GridQueryCellInfoEventArgs e)
{
if (!pivotGrid1.EnableValueEditing)
return;
if (e.Cell.RowIndex < pivotGrid1.PivotEngine.RowCount && e.Cell.ColumnIndex < pivotGrid1.PivotEngine.ColumnCount && (pivotGrid1.PivotEngine.ColumnCount > 1 && pivotGrid1.PivotEngine.RowCount > 1))
{
PivotCellInfo pi = pivotGrid1.PivotEngine[e.Cell.RowIndex, e.Cell.ColumnIndex];
if (pi != null && (pi.CellType & PivotCellType.ValueCell) != 0
&& (pivotGrid1.EditManager.AllowEditingOfTotalCells || (pi.CellType & PivotCellType.TotalCell) == 0
&& (pi.CellType & PivotCellType.GrandTotalCell) == 0)
)
{
this.pivotGrid1.InternalGrid.Model[e.Cell.RowIndex, e.Cell.ColumnIndex].CellType = "DataBoundTemplate";
this.pivotGrid1.InternalGrid.Model[e.Cell.RowIndex, e.Cell.ColumnIndex].CellItemTemplateKey = "TextTemplate";
this.pivotGrid1.InternalGrid.Model[e.Cell.RowIndex, e.Cell.ColumnIndex].CellEditTemplateKey = "Textboxtemplate";
}
}
}
 

 

C:\Users\labuser\Dropbox\Screenshots\Screenshot 2014-06-04 16.55.46.png

Figure: Pivot Grid shows Editing Behaviour

 

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment
Access denied
Access denied