We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

SelectedItems in pivot control is always null

Thread ID:

Created:

Updated:

Platform:

Replies:

143135 Mar 6,2019 02:28 AM UTC Mar 7,2019 06:47 AM UTC WPF 4
loading
Tags: PivotGridControl
Carlos Fernando Consigli
Asked On March 6, 2019 02:28 AM UTC

Hello, I'm trying to generate some charts from selected cells in a pivot control. I set AllowSelection = true but when I try to get selected cells from pivotGrid1.SelectedItems I'm always getting null. Same happens with pivotGrid1.SelectedCell although I guess the latter does not apply on multiple selection. Is that the correct way of accessing selected cells?
Thanks in advance.

Arulraj A [Syncfusion]
Replied On March 6, 2019 11:55 AM UTC

Hi Carlos, 

Thanks for using Syncfusion product. 

We are unable to reproduce the reported issue “SelectedItems value is null while selecting the cells in pivot grid”. Based on the cell selection values in pivot grid, the selected item values are correctly displayed in the listbox. Also, We cannot see any null values while selecting the cells in pivot grid control. 

Please refer the attached videos and sample from the following location: 

Also, refer our UG documentation from the  following link: 

Could you please share your working sample or modify the attached sample in order to reproduce the reported issue, so that it could be helpful to proceed further. 

Regards, 
Arulraj A 


Carlos Fernando Consigli
Replied On March 6, 2019 12:27 PM UTC

Hi Arulraj. Thanks for your quick answer. Maybe I'm not using this property as it is supposed to. I'm trying to access the SelectedItems from code behind. I'm attaching a sample showing something similar to what I'm trying to do and how in that case I get null values.
Greetings

Attachment: SampleSelectedItems_e4537553.zip

Carlos Fernando Consigli
Replied On March 6, 2019 06:42 PM UTC

Ok, I figured it out and solved it. I don't know if this is intended or it's a bug, but I solved it by just binding an empty handler to SelectionChanged. Now SelectedItems is not null any more when I access it from code behind.

....
pivotGrid.SelectionChanged += PivotGrid_SelectionChanged;
.....

private void PivotGrid_SelectionChanged(object sender, PivotGridSelectionChangedEventArgs e)
{     
}

Again, maybe this is a design decision based on performance ("Why update SelectedItems collection if there is no handler bound to SelectionChanged event?") or it maybe is indeed a minor bug.
Thanks again for your quick support.



Arulraj A [Syncfusion]
Replied On March 7, 2019 06:47 AM UTC

Hi Carlos, 

Thanks for the update. 

The reported behavior is the default behavior of pivot grid and it is not a bug. The SelectedItems property values are assigned while triggering the SelectionChanged event handler only. Otherwise, you’ll get the null values in the SelectedItems property. Using the event handler, you’ll get the SelectedItems and then you can render the chart in your application based on the selected items. 

Please refer the below code sample: 

#MainWindow.xaml.cs 
 
        private object selectedItem; 
        public MainWindow() 
        { 
            InitializeComponent(); 
            pivotGrid1.SelectionChanged += PivotGrid1_SelectionChanged; 
        } 
 
        private void PivotGrid1_SelectionChanged(object sender, Syncfusion.Windows.Controls.PivotGrid.PivotGridSelectionChangedEventArgs e) 
        { 
            selectedItem = e.SelectedItems; 
        } 
 

Please find the modified sample from the following location: 

Please let us know if you need any further assistance. 

Arulraj A 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;