I have a grid and a chart bound to a collection called MyData. When I filter that collection on the grid, I want MyData to update with the filtered values.
I have looked at RadDataFilter but it's usability was not at all what we want (takes too much space for one and it's simpler to filter in the grid) so I was wondering if there is anyway the Grid can announce the new filtered data to the MyData collection so the chart can populate with the filtered values.
Thanks.
15 Answers, 1 is accepted
You can bind the chart to the grid Items collection if you want the chart to respect filtering, sorting, etc.
Regards,Vlad
the Telerik team
Time to cast your vote for Telerik! Tell DevPro Connections and Windows IT Pro why Telerik is your choice. Telerik is nominated in a total of 25 categories.
I did:
MySLchart.DataContext = RadGrid.Items;
Filtering the grid doesn't update the chart still.
Thanks for further help.
The correct syntax would be:
MyRadChart.ItemsSource = RadGrid.ItemsSource/Items;
Hope this helps!
Kind regards,
Nik
the Telerik team
Time to cast your vote for Telerik! Tell DevPro Connections and Windows IT Pro why Telerik is your choice. Telerik is nominated in a total of 25 categories.
Thanks a lot guys, great support.
Have a great day,
Hakki.
Here is the grid and chart I am working with: http://i230.photobucket.com/albums/ee248/masteratt/telerikchart.png
Is there any way the chart can change it's X-axis based on what the user is grouping the grid by? So if they group by patient, the X-axis will be 331, 555 and label will say Patient.
Also if Patient 331 has multiple Queries Raised, I would want to add them up when being grouped by Patient. It did not do that.
Basically is there an event to let me know grid filtering has changed so I can build logic around it.
Thanks.
If you bind the chart to the grid Items collection as I already suggested you this will be handled automatically.
Greetings,Vlad
the Telerik team
Time to cast your vote for Telerik! Tell DevPro Connections and Windows IT Pro why Telerik is your choice. Telerik is nominated in a total of 25 categories.
Please have a look at my code:
//under InitializeComponent
RadGrid.ItemsSource = MyData;
Then setting the chart:
var seriesMapping =
new
SeriesMapping { LegendLabel =
"Query Raised"
};
seriesMapping.ItemMappings.Add(
new
ItemMapping(
"QueryRaisedColumn"
, DataPointMember.YValue));
//seriesMapping.ItemMappings.Add(new ItemMapping("PatientColumn", DataPointMember.XCategory));
seriesMapping.SeriesDefinition =
new
StackedBarSeriesDefinition { ShowItemLabels =
false
};
var seriesMapping2 =
new
SeriesMapping { LegendLabel =
"Query Resolved"
};
seriesMapping2.ItemMappings.Add(
new
ItemMapping(
"QueryResolvedColumn"
, DataPointMember.YValue));
//seriesMapping2.ItemMappings.Add(new ItemMapping("PatientColumn", DataPointMember.XCategory));
seriesMapping2.SeriesDefinition =
new
StackedBarSeriesDefinition { ShowItemLabels =
false
};
var seriesMapping3 =
new
SeriesMapping { LegendLabel =
"Query Outstanding"
};
seriesMapping3.ItemMappings.Add(
new
ItemMapping(
"QueryOutstandingColumn"
, DataPointMember.YValue));
//seriesMapping3.ItemMappings.Add(new ItemMapping("PatientColumn", DataPointMember.XCategory));
seriesMapping3.SeriesDefinition =
new
StackedBarSeriesDefinition { ShowItemLabels =
false
};
MyRadChart.ItemsSource = RadGrid.Items;
MyRadChart.DefaultView.ChartArea.AxisY.AutoRange =
false
;
MyRadChart.DefaultView.ChartArea.AxisY.Step = 1;
MyRadChart.SeriesMappings.Add(seriesMapping);
MyRadChart.SeriesMappings.Add(seriesMapping2);
MyRadChart.SeriesMappings.Add(seriesMapping3);
I commented out the Xcategory as I thought not setting it might allow the itemsource to change it but no dice.
Ungrouped: http://i230.photobucket.com/albums/ee248/masteratt/telerik1.png
Grouped: http://i230.photobucket.com/albums/ee248/masteratt/telerik2.png
For the grouped, I want X axis to become two (one for each centre) and the YValue to add up ALL the queries resolved/raised/outstanding in that centre.
Thanks for helping me achieve this!
You need to bind ItemsSource to Items instead simple assignment.
Greetings,Vlad
the Telerik team
Time to cast your vote for Telerik! Tell DevPro Connections and Windows IT Pro why Telerik is your choice. Telerik is nominated in a total of 25 categories.
I am however not sure what you mean, I thought I was already doing that with this line:
MyRadChart.ItemsSource = RadGrid.Items;
Can you elaborate and maybe code up a quick example using my code above.
Much appreciated.
I strongly suggest you to check MSDN for more info about Binding:
http://msdn.microsoft.com/en-us/library/system.windows.data.binding(v=vs.95).aspx
Vlad
the Telerik team
Time to cast your vote for Telerik! Tell DevPro Connections and Windows IT Pro why Telerik is your choice. Telerik is nominated in a total of 25 categories.
<
telerikChart:RadChart
x:Name
=
"MyRadChart"
Margin
=
"8,297,6,39"
telerik:StyleManager.Theme
=
"Metro"
ItemsSource
=
"{Binding ElementName=RadGrid, Path=Items}"
/>
Isn't that right? If wrong, how?
Again, the chart updates with the grid's filtered data fine to an extend but not to my specific needs (see this post above).
I feel this got more confusing than it needed to, apologies...However further help is much appreciated. Some examples perhaps?
You can check the attached project for reference.
Regards,Vlad
the Telerik team
Time to cast your vote for Telerik! Tell DevPro Connections and Windows IT Pro why Telerik is your choice. Telerik is nominated in a total of 25 categories.
There is a misunderstanding as to what I am now asking I think. The thread title is now sorted and I guess I should have made a new thread with this new query but here are the functions that are missing from that:
Please take a look at this grid/chart: http://i230.photobucket.com/albums/ee248/masteratt/telerikNoGroup_zps982dffc6.png
Now when I group it by Centre. I want Centre 1 to have 3 Query Outstanding and 3 Query Raised (i.e: adding the columns up in that centre as it was grouped by it) so the stack bar displays accurate information based on grouping.
Where as now it doesn't display it very accurately after I group it: http://i230.photobucket.com/albums/ee248/masteratt/telerikGroup_zpsc0123996.png
As you can see it doesn't add up the query numbers for per centre.
And if I group by Patient, I would want the axis to become 555, 331, 666 (which it doesn't) and again adding the Query columns up based on patient and so on.
The way you worked binding in your example project is identical to how I did so I can confirm that code does not provide the functionality I am asking for here.
If you can provide a reference project (or link to help files) that helps me achieve what I asked for here, it will be immensely appreciated.
Sorry for not creating a separate thread for it (perhaps I should now?), it caused unnecessary confusion but further help would be appreciated.
Thanks in advance.
Yes I would ask you to open a new thread and explain your requirements there. This is because we are trying to keep different issues in different threads as it eases the communication process. I have anyway attached a simple project that demonstrates how grouping can work between the grid view and chart, but this is only to give you a head start. Open a new thread and we will do our best to assist you.
Greetings,
Petar Marchev
the Telerik team
Time to cast your vote for Telerik! Tell DevPro Connections and Windows IT Pro why Telerik is your choice. Telerik is nominated in a total of 25 categories.