Dears,
In the samples, in the conditional formatting section of the pivot grid, i notice that when i scroll in the grid or change anything, the bars of the Bikes column are changing in width, even that the cost (number besides the bar) did not change, how is that??
i need to re implement this but on the header row ,and i did it, but the change issue, when the values is not changed, this is conflicting
Please need ur help
Hi
The changing that you see is the changing of column’s width. This is that because the content of grid is generated on demand and only the cells in visual area are rendered and shown.
The column’s width is set to fit the cells content and not to clip it. If you want to set fixed width you can do it by setting ColumnWidth property like below:
pivotGrid.DataColumns[0].ColumnWidth = 200;
Regards,
Todor
http://samples.infragistics.com/sldv/RunSamples.aspx?cn=pivot-grid#/pivot-grid/conditional-formatting
in this sample, if u look at the Bikes column, and look at the red rectangle of alfredo, with the value 75,949 and check the width of it, then u scroll down the grid, and go up again to the alfredo, u can c that the value 75,949 is the same, but the red bar width changed.
it is supposed that the width of the red bar is linked to the value.
what if i want all the grid to be rendered, not only the showing area.
am doing the same here, but with the header row, i want to put a colored rectangle near the row name, and the color depends on the row name. so also when i scroll the grid, different colors are displayed for the same color name, and this is not what i want :S
Could you post the code you colored the header row with. So can see that is going on
Sure :)
Where excatly is the code where you make colored. The project is too big
in the mainpage.cs
public class Converter : IValueConverter { #region IValueConverter Members public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { PivotRowHeaderCellControl cellControl = value as PivotRowHeaderCellControl; PivotRowHeaderCell cell = cellControl.Cell as PivotRowHeaderCell; string color = "Transparent"; String[] _brushes = new String[] {new SolidColorBrush(Color.FromArgb(178,(byte)0,(byte)106,(byte)53)).Color.ToString(), new SolidColorBrush(Color.FromArgb(153,(byte)174,(byte)0,(byte)0)).Color.ToString(), new SolidColorBrush(Color.FromArgb(153,(byte)64,(byte)0,(byte)64)).Color.ToString(), new SolidColorBrush(Color.FromArgb(153,(byte)141,(byte)181,(byte)233)).Color.ToString(), new SolidColorBrush(Color.FromArgb(153,(byte)128,(byte)255,(byte)128)).Color.ToString(), new SolidColorBrush(Color.FromArgb(153,(byte)128,(byte)128,(byte)128)).Color.ToString(), new SolidColorBrush(Color.FromArgb(153,(byte)128,(byte)0,(byte)128)).Color.ToString(), new SolidColorBrush(Color.FromArgb(153,(byte)0,(byte)119,(byte)176)).Color.ToString(), new SolidColorBrush(Color.FromArgb(153,(byte)0,(byte)0,(byte)0)).Color.ToString(), new SolidColorBrush(Color.FromArgb(153,(byte)0,(byte)0,(byte)0)).Color.ToString(), new SolidColorBrush(Color.FromArgb(153,(byte)0,(byte)0,(byte)0)).Color.ToString(), new SolidColorBrush(Color.FromArgb(153,(byte)0,(byte)0,(byte)0)).Color.ToString(), new SolidColorBrush(Color.FromArgb(153,(byte)0,(byte)0,(byte)0)).Color.ToString(), new SolidColorBrush(Color.FromArgb(153,(byte)0,(byte)0,(byte)0)).Color.ToString(), new SolidColorBrush(Color.FromArgb(153,(byte)0,(byte)0,(byte)0)).Color.ToString(), new SolidColorBrush(Color.FromArgb(153,(byte)0,(byte)0,(byte)0)).Color.ToString(), new SolidColorBrush(Color.FromArgb(153,(byte)0,(byte)0,(byte)0)).Color.ToString(), new SolidColorBrush(Color.FromArgb(178,(byte)0,(byte)119,(byte)176)).Color.ToString()}; //MessageBox.Show(_brushes[0]); List<brands> uniquebrands = new List<brands>(); string cbrand; int brandcount; XElement xDocument = XElement.Load("CommonDS.xml"); var v = from g in xDocument.Descendants("categorybrand") where (string)g.Element("programid").Value == "9544" && (string)g.Element("marketref").Value == "5E8256B0-3860-460A-8E40-8069A7A6199E" select g.Element("brandref"); foreach (var item in v) { if (!uniquebrands.Contains(new brands(item.Value))) { uniquebrands.Add((new brands(item.Value))); } } brandcount = uniquebrands.Count; for (int nbrand = 0; nbrand < brandcount; nbrand++) { cbrand = uniquebrands.ElementAt(nbrand).brandref; if (cbrand == cell.RealRow.HeaderText) { color = _brushes[nbrand]; break; } } return color; } public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { return value; } #endregion }in the mainpage.xaml
<ig:XamPivotGrid Grid.Column="0" Grid.Row="2" RowHeaderStyle="{StaticResource RowHeaderCellStyle}" AllowCompactLayout="True" DataSource="{StaticResource FlatDataSource}" x:Name="pivotGrid" AllowHeaderColumnsSorting="False" AllowHeaderRowsSorting="False" > <ig:XamPivotGrid.EditSettings> <ig:EditSettings AllowCellEdit="True"/> </ig:XamPivotGrid.EditSettings> <ig:XamPivotGrid.FiltersAreaSettings> <ig:FiltersAreaSettings EmptyHeaderAreaContent="" HeaderAreaStyle="{StaticResource FilterDropAreaStyle}"></ig:FiltersAreaSettings> </ig:XamPivotGrid.FiltersAreaSettings> <ig:XamPivotGrid.MeasuresAreaSettings> <ig:MeasuresAreaSettings EmptyHeaderAreaContent="" HeaderAreaStyle="{StaticResource measureDropAreaStyle}"></ig:MeasuresAreaSettings> </ig:XamPivotGrid.MeasuresAreaSettings> <ig:XamPivotGrid.ColumnsAreaSettings> <ig:ColumnsAreaSettings EmptyHeaderAreaContent="" HeaderAreaStyle="{StaticResource columnsDropAreaStyle}"></ig:ColumnsAreaSettings> </ig:XamPivotGrid.ColumnsAreaSettings> </ig:XamPivotGrid>
<Style x:Key="RowHeaderCellStyle" TargetType="ig:PivotRowHeaderCellControl"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="ig:PivotRowHeaderCellControl"> <igPivotPrim:PivotSimpleClickableContainer BorderBrush="{TemplateBinding BorderBrush}"> .......................................................... ..........................................................
......................................................... ..........................................................
<Grid x:Name="headerGrid" Grid.Column="1"> <StackPanel Orientation="Horizontal"> <Rectangle Margin="3" HorizontalAlignment="Left" VerticalAlignment="Stretch" Fill="{Binding RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource converter}}" Height="10" Width="10"/>
this is the rectangle that am drawing
You should add the path to your binding. This will ensure you that the converter will be called correct. Now due to virtialization the color is set once and when the cell is reused from another cell the color is the same. When you set path in binding thanks to property change event the framework knows that the converter should be called and correct color will be used. Below is a snippet how to change it
<Rectangle Margin="3" HorizontalAlignment="Left" VerticalAlignment="Stretch" Fill="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Cell, Converter={StaticResource colorConverter}}" Height="10" Width="10"/>
Look at the path property. Path=Cell