Hello!
I have a measure of my custom type "SplitValue", so my data is split in two parts and in PivotGrid the sum of two parts is shown. I've already managed to show these values in PivotGrid by writing custom aggregator, but I need to edit both of underlying values. I want to create a edit template with two textboxes instead of one, but I can't find a way to do this.
How can I do this?
Hello and thank you for posting!
I have been looking into your scenario and a possible solution here would be create the cell template like it is described in the following documentation page http://help.infragistics.com/Help/Doc/WPF/2014.1/CLR4.0/html/xamPivotGrid_Customizing_Cells_with_Templates_Procedure_and_Code_Example.html and apply it when the CellEnterEdit event is fired.Please feel free to let me know if you have any questions or concerns.
But how do I remove that template when editing has finished? OnCellEdited event only fires when editing is approved, but how to revert the template when edit is canceled (Esc is pressed)?
Thank you for your feedback and for using Infragistics components. I am glad the issue is resolved.
Thank you Maria, yes, your answer pointed me in the right direction.
Hello,
I am just checking if you have any other questions on getting the underlying data of a cell.
Hi,
I am glad that the suggested approach helps you get closer to the functionality you need. The approach that is suggested by Plamen in the following forum thread is regarding the access to the underlying data: http://ko.infragistics.com/community/forums/t/56647.aspx Here is how I have modified the approach so that it suits to the project I have previously attached:private void pivotGrid_CellEditing(object sender, Infragistics.Controls.Grids.PivotCellEditingEventArgs e) { int units = 0; StackPanel panel = Infragistics.Windows.Utilities.GetDescendantFromType(e.Editor, typeof(StackPanel), false) as StackPanel; int columnIndex = pivotGrid.DataColumns.IndexOf(e.Cell.DataColumn); int rowIndex = pivotGrid.DataRows.IndexOf(e.Cell.DataRow); FlatDataSource flatDataSource = (FlatDataSource)this.pivotGrid.DataSource; List<int> itemsIndexes = flatDataSource.GetCellItemsIndexes(pivotGrid.DataSource.Result.Cells[rowIndex, columnIndex]); foreach (int itemIndex in itemsIndexes) {
object dataItem = flatDataSource.GetRecord(itemIndex); units += ((Sale)dataItem).NumberOfUnits; } (panel.Children[1] as TextBox).Text = units.ToString();}I hope it will be useful.
Thank you Maria! That's what I want.
The only issue that I have left now is: how to bind to underlying value of the cell? All I can do yet is to bind to the string representation of this object. I wrote a custom aggregator, so now I have correct objects, but can't bind to them.