This is a migrated thread and some comments may be shown as answers.

Set ItemMapping FieldName Property By DataBinding

1 Answer 41 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Martyn
Top achievements
Rank 1
Martyn asked on 09 May 2012, 03:30 PM
Hi,

In my RadChart, I currently set the FieldName of the SeriesMapping.ItemMapping statically. However, I want to be able to change which field within the dataset is being plotted dynamically at runtime.

I've set the FieldName to be set with a binding and the chart initially draws, but, when I change the property being bound to, the chart does not re-draw to reflect this change.

<telerik:SeriesMapping>
                            <telerik:SeriesMapping.SeriesDefinition>
                                <telerik:StackedBarSeriesDefinition ShowItemToolTips="True" ItemToolTipFormat="{StaticResource HomeDealerChartCurrTooltip}"
                                                             ItemLabelFormat="{StaticResource OverspendTooltipLabelFormat}" ItemStyle="{StaticResource StackedBarDefaultStyle}">
                                    <telerik:StackedBarSeriesDefinition.InteractivitySettings>
                                        <telerik:InteractivitySettings HoverScope="Series" SelectionScope="Item" />
                                    </telerik:StackedBarSeriesDefinition.InteractivitySettings>
                                </telerik:StackedBarSeriesDefinition>
                            </telerik:SeriesMapping.SeriesDefinition>
 
                            <telerik:SeriesMapping.ItemMappings>
                                <telerik:ItemMapping FieldName="OverspendToDate" DataPointMember="YValue" />
                                <telerik:ItemMapping FieldName="{Binding SelectedMeasure}" DataPointMember="XCategory" />
                            </telerik:SeriesMapping.ItemMappings>
                        </telerik:SeriesMapping>

Am I missing something?

Thanks for any help,

Martyn.

1 Answer, 1 is accepted

Sort by
0
Petar Marchev
Telerik team
answered on 14 May 2012, 09:08 AM
Hi Martyn,

The ItemMappingCollection does not implement the INotifyItemChanged interface, hence it does not track changes in the items' properties. This means that you are not doing anything wrong, its just that this behavior is not expected.

You can either create a new SeriesMapping and add it to the SeriesMappings collection (and remove the old mapping) or you need to call the Rebind method of the chart when you update the ItemMapping. 

Greetings,
Petar Marchev
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Tags
Chart
Asked by
Martyn
Top achievements
Rank 1
Answers by
Petar Marchev
Telerik team
Share this question
or