- Home
- Forum
- Xamarin.Forms
- Datagrid Grouping Error When ItemSource has changed.
Datagrid Grouping Error When ItemSource has changed.
Hello,
I am trying to implement a datagrid on the mobile app. here is my problem i have xaml code that is grouped by date variable in grouping mode. and i am trying to fetchdata as you see above i am directly creating a new observablecollection and assigning it to binded variable in this example Campaigns is the property that is binded to xaml
I am trying to implement a datagrid on the mobile app. here is my problem i have xaml code that is grouped by date variable in grouping mode. and i am trying to fetchdata as you see above i am directly creating a new observablecollection and assigning it to binded variable in this example Campaigns is the property that is binded to xaml
private async Task FetchChartDataAsync()
{
_isFetchingData = true;
await WebRequestExecuter.Execute(async () => await _camnpaignsAppService.GetSalesStats(_input), result =>
{
//Campaigns.Clear();
//Sales.Clear();
var campaigns = ObjectMapper.Map<List<CampaignSummaryModel>>(result.Campaigns);
var salesSummary = ObjectMapper.Map<List<SalesSummaryModel>>(result.Sales);
foreach (var campaign in campaigns)
{
campaign.DateType = _input.Type;
Campaigns.Add(campaign);
}
foreach (var sale in salesSummary)
{
sale.DateType = _input.Type;
Sales.Add(sale);
}
//OnPropertyChanged("Campaigns");
//OnPropertyChanged("Sales");
var campaignsObservable = new ObservableCollection<CampaignSummaryModel>(campaigns);
var salesObservable = new ObservableCollection<SalesSummaryModel>(salesSummary);
Campaigns = campaignsObservable;
Sales = salesObservable;
_isFetchingData = false;
return Task.CompletedTask;
});
}
here is the partial xaml code.
<dataGrid:SfDataGrid x:Name="SalesGrid"
ItemsSourceChanged="DataGrid_ItemsSourceChanged"
AutoExpandGroups="False"
ItemsSource="{Binding Campaigns}"
ColumnSizer="Star"
AutoGenerateColumns="False"
AllowGroupExpandCollapse="True"
HorizontalOptions="FillAndExpand"
VerticalOptions="FillAndExpand"
GroupingMode="Multiple"
AllowSorting="True" >
......
......
......
<dataGrid:SfDataGrid.CaptionSummaryRow>
<dataGrid:SfDataGrid.CaptionSummaryRow>
<dataGrid:GridSummaryRow ShowSummaryInRow="True" Title="Total: {NetPrice}, {DateStr}">
<dataGrid:GridSummaryRow.SummaryColumns>
<dataGrid:GridSummaryColumn Name="DateStr" Format="{}{DateStr}" MappingName="DateStr" SummaryType="Custom" CustomAggregate="{StaticResource gridAggregate}" />
<dataGrid:GridSummaryColumn Name="NetPrice" Format="{}{NetPrice}" MappingName="NetPrice" SummaryType="Custom" CustomAggregate="{StaticResource gridAggregate}" />
</dataGrid:GridSummaryRow.SummaryColumns>
</dataGrid:GridSummaryRow>
</dataGrid:SfDataGrid.CaptionSummaryRow>
<dataGrid:SfDataGrid.GroupColumnDescriptions>
<dataGrid:GroupColumnDescription ColumnName="PeriodDate"/>
</dataGrid:SfDataGrid.GroupColumnDescriptions>
</dataGrid:SfDataGrid>
and this works fine when it is first binded but when i update the data from the server according to parameters that the user is changing i am getting a object reference not to set an instance of object exception. Do you have any idea or suggestions about it?
here is the partial stacktrace for the error that i am getting.
As a note if i do not create it with new ObservableCollection<CampaignSummaryModel>(campaigns);
then i don't get the error but in groupsummary the aggregate functions are not right. it shows only the first element's price instead of sum.
Thank you for the assistance.
here is the partial stacktrace for the error that i am getting.
at Syncfusion.SfDataGrid.XForms.CaptionSummaryRowControl.LayoutChildren (System.Double x, System.Double y, System.Double width, System.Double height) [0x0002f] in <97e0e93585274364a86d4de6550b97c6>:0
at Xamarin.Forms.Layout.UpdateChildrenLayout () [0x00158] in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:266
at Xamarin.Forms.Layout.OnSizeAllocated (System.Double width, System.Double height) [0x0000f] in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:224
at Xamarin.Forms.VisualElement.SizeAllocated (System.Double width, System.Double height) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:784
at Xamarin.Forms.Layout.ForceLayout () [0x00000] in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:125
at Syncfusion.SfDataGrid.XForms.VisualContainer.ArrangeRows () [0x00773] in <97e0e93585274364a86d4de6550b97c6>:0
at Syncfusion.SfDataGrid.XForms.VisualContainer.LayoutChildren (System.Double x, System.Double y, System.Double width, System.Double height) [0x00000] in <97e0e93585274364a86d4de6550b97c6>:0
at Xamarin.Forms.Layout.UpdateChildrenLayout () [0x00158] in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:266
at Xamarin.Forms.Layout.OnSizeAllocated (System.Double width, System.Double height) [0x0000f] in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:224
at Syncfusion.SfDataGrid.XForms.VisualContainer.OnSizeAllocated (System.Double width, System.Double height) [0x0041c] in <97e0e93585274364a86d4de6550b97c6>:0
then i don't get the error but in groupsummary the aggregate functions are not right. it shows only the first element's price instead of sum.
Thank you for the assistance.
SIGN IN To post a reply.
7 Replies
KK
Karthikraja Kalaimani
Syncfusion Team
March 3, 2020 01:31 PM UTC
Hi Can Gunaydin,
Thank you for contacting Syncfusion support.
Since we are not aware of your exact application scenario, could you please share the following details to check it further and provide a possible solution at earlier.
Thank you for contacting Syncfusion support.
Since we are not aware of your exact application scenario, could you please share the following details to check it further and provide a possible solution at earlier.
i) SfDataGrid settings and custom aggregate settings
ii) SfDataGrid Version
iii) Xamarin Forms Version
iv) Which platform you are facing this issue?
v) ViewModel file
vi) Model file
vii) If possible, can you please share the issue reproducing sample along with replication procedure or Modify the below attached sample based on your scenario and revert us back with clear replication procedure.
Sample link : https://www.syncfusion.com/downloads/support/directtrac/general/ze/DataGridDemo1101267619-351925139.zip
Karthik Raja
CG
Can Gunaydin
March 3, 2020 04:34 PM UTC
Hello here is the files that you want.
i didn't include everything cause of dependencies but i included viewmodel,model,xaml,gridAggregate files
i use sfDataGrid version v17.4.0.51
i use Xamarin.Forms v4.4.0.991477
Attachment: Files_b444ed46.zip
i didn't include everything cause of dependencies but i included viewmodel,model,xaml,gridAggregate files
i use sfDataGrid version v17.4.0.51
i use Xamarin.Forms v4.4.0.991477
i use android emulator that's where i have found the issue.
i tried to reproduce the problem in your sample i am uploading it also. But that was another error and another behavior in the demo.
Maybe you can look at it and tell me what's going wrong over there but basically the idea of how i want to bind is over there.
Thank you for the assistance
i tried to reproduce the problem in your sample i am uploading it also. But that was another error and another behavior in the demo.
Maybe you can look at it and tell me what's going wrong over there but basically the idea of how i want to bind is over there.
Thank you for the assistance
Attachment: Files_b444ed46.zip
KK
Karthikraja Kalaimani
Syncfusion Team
March 4, 2020 12:34 PM UTC
Hi Can Gunaydin,
Thank you for the update.
Based on your provided details we have checked the reported issue “Null Reference Exception thrown when changing ItemSource at runtime with CaptionSummaryRow ” and we could able to reproduce the issue. We have logged the bug report for the same. We will fix this issue and include the issue fix in our upcoming weekly nuget which is scheduled on 17th March 2020. We appreciate your patience until then.
Thank you for the update.
Based on your provided details we have checked the reported issue “Null Reference Exception thrown when changing ItemSource at runtime with CaptionSummaryRow ” and we could able to reproduce the issue. We have logged the bug report for the same. We will fix this issue and include the issue fix in our upcoming weekly nuget which is scheduled on 17th March 2020. We appreciate your patience until then.
You can also track the status of the report in below feedback link,
https://www.syncfusion.com/feedback/12504/nullrefrence-exception-thrown-when-changing-itemsource-at-runtime-with
Regards,
Karthik Raja
https://www.syncfusion.com/feedback/12504/nullrefrence-exception-thrown-when-changing-itemsource-at-runtime-with
Regards,
Karthik Raja
KK
Karthikraja Kalaimani
Syncfusion Team
March 17, 2020 01:54 PM UTC
Hi Can Gunaydin,
Thank you for your patience.
We have fixed the reported issue and please let us know in which SfDataGrid version you want to provide patch.
Regards,
Thank you for your patience.
We have fixed the reported issue and please let us know in which SfDataGrid version you want to provide patch.
Regards,
Karthik Raja
CG
Can Gunaydin
March 17, 2020 06:28 PM UTC
Hello,
Thank you for your help. Right now i am at testing environment so it doesn't matter so much for me. Right now i use v17.4.0.51. But i can switch to the latest version if it is fixed on the latest version.
Thank you for your help. Right now i am at testing environment so it doesn't matter so much for me. Right now i use v17.4.0.51. But i can switch to the latest version if it is fixed on the latest version.
FP
Farjana Parveen Ayubb
Syncfusion Team
March 18, 2020 08:56 AM UTC
Hi Can Gunaydin,
Thank you for your update.
As we updated earlier, we have fixed the reported issue and it will be including in our 2020 Volume 1 release and it will be available on end of March 2020.
Regards,
Farjana Parveen A
KK
Karthikraja Kalaimani
Syncfusion Team
April 3, 2020 05:24 AM UTC
Hi Can Gunaydin,
We are glad to announce that our Essential Studio 2020 Volume 1 main Release version 18.1.0.42 is rolled out with the reported bug fix “Null Reference Exception thrown when changing ItemSource at runtime with CaptionSummaryRow” and is available for download under the following link.
We thank you for your support and appreciate your patience in waiting for this release. Please get in touch with us if you would require any further assistance.
Regards,
Karthik Raja
SIGN IN To post a reply.
- 7 Replies
- 3 Participants
-
CG Can Gunaydin
- Mar 2, 2020 02:58 PM UTC
- Apr 3, 2020 05:24 AM UTC