I have a XamGrid and a combobox on my xaml page. Based on what value I select in the combobox, WCF returns the data and I set it as the ItemSource of the XamGrid. I am using DataTable to bind the data to the grid.
public partial class Report: Page { private DataTable resultData; . . void proxy_GetDataCompleted(object sender, EventArgs e) { resultData = new DataTable(e.Result); webGridView.ItemSource = resultData; }
Now everytime I change the selection on the combobox, I do get different datasource from the WCF service (dataset has different columns) and even the data is bound correctly on the UI. For the first time the data is bound, I do see a valid count in webGridView.Columns, however for subsequent databindings, the data seems nicely bound on the grid/UI but the count on webGridView.Columns is 0 and I cannot access each of the columns. Even if I call invalidateData() before binding the new data source, it doesnt work. I apply formatting to the data programaticallly. Now since I cant access the columns when the itemsource has changed, the formatting rules arent applied. How do I fix it?
Hi,
I would recommend that you first have some logic that looks to see if the xamGrid is loaded by using the xamGrid Loaded event. If the comboBox changed before the xamGrid is loaded you can then call a method that performs your column logic.
As for the summaries, as long as you're setting the ItemsSource to null, that will invalidate the columns that were previously there, and allow you apply the summaries.
-SteveZ
Yes, summary doesnt seem to be applied even if call it after this.Dispatcher.BeginInvoke. How do I get this to work with the code? The datasources we use in our application is dynamic as shown in the sample and therefore I would need a workaround. Any help will be appreciated. Thanks
I tried your sample, and yes you'll need to set the ItemSource to null to make sure and clear out any cached information.
However, the Summary code you posted appears to work just fine.
One note, it won't get into the code in your sample in the initial call to that method, b/c the xamGrid hasn't loaded, and the ItemsSource will not load until the xamGrid has been loaded, so you may need to delay the call the initial time.
SteveZ, any updates on this?
Thanks Harshb, setting itemsource as null before rebinding works.
Also, I am trying to set SumSummaryOperand's IsApplied property as true for all numeric columns in the code behind but it doesnt apply. Is this related issue?
foreach (SummaryOperandBase operand in col.SummaryColumnSettings.SummaryOperands) { if (operand is SumSummaryOperand) operand.IsApplied = true; }