Hi Team,
We have a Xamdatagrid with around 20 columns which are editable and virtualization is enabled on the grid , we are able to load and edit the data without any issues .
But when we use the grid’s scrollbar to view the records , the data from some of the columns (specifically columns which use XamMultiColumnCombo) are disappearing as we scroll .
We have tried to set the RecordContainerGenerationMode to lazyload or preload which solves the issue , but has significant performance impact .So we can't go with this solution.
This is happening specifically on the cells which use XamMultiColumnCombo editor , the selected item is getting triggered on the combo when we use the scrollbar on the xamdatagrid.
Any help to resolve this issue is greatly appreciated.
Current version of IG : 14.1
Here is the snippet of the column in which we are noticing the above issue,
<dataPresenter:UnboundField Label="Order Placer" Visibility="{Binding Source={StaticResource Proxy}, Path=Data.ShowCol, Converter={StaticResource BoolToCollapseVisibilityConverter}}"> <dataPresenter:Field.Settings> <dataPresenter:FieldSettings AllowEdit="True" LabelTextAlignment="Center" LabelTextWrapping="Wrap" Width="140" CellValuePresenterStyle="{StaticResource EditableCellValuePresenterStyle}"> <dataPresenter:FieldSettings.EditorStyle> <Style TargetType="{x:Type editors:XamTextEditor}"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type editors:XamTextEditor}"> <Grid IsEnabled="{Binding DataItem.IsEnabled}"> <StackPanel DataContext="{Binding DataItem.DsViewModel}"> <ig:XamMultiColumnComboEditor x:Name="TestCombo" AutoGenerateColumns="False" DropDownButtonDisplayMode="Always" SelectedItemsResetButtonVisibility="Collapsed" ItemsSource="{Binding Orders}" DisplayMemberPath="Name" SelectedItem="{Binding SelectedOrder, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" FilterMode="FilterOnAllColumns" MinDropDownWidth="320" > <ig:XamMultiColumnComboEditor.Columns> <ig:TextComboColumn Key="Name"/> </ig:XamMultiColumnComboEditor.Columns> </ig:XamMultiColumnComboEditor> </StackPanel> </Grid> </ControlTemplate> </Setter.Value> </Setter> <Setter Property="EditTemplate"> <Setter.Value> <ControlTemplate TargetType="{x:Type editors:XamTextEditor}"> <Grid IsEnabled="{Binding DataItem.IsEnabled}"> <StackPanel DataContext="{Binding DataItem.DsViewModel}"> <ig:XamMultiColumnComboEditor x:Name="OrderPlacerCombo" AutoGenerateColumns="False" DropDownButtonDisplayMode="Always" SelectedItemsResetButtonVisibility="Collapsed" ItemsSource="{Binding Orders}" DisplayMemberPath="Name" SelectedItem="{Binding SelectedOrder, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" FilterMode="FilterOnAllColumns" MinDropDownWidth="320" > <ig:XamMultiColumnComboEditor.Columns> <ig:TextComboColumn Key="Name"/> </ig:XamMultiColumnComboEditor.Columns> </ig:XamMultiColumnComboEditor> </StackPanel> </Grid> </ControlTemplate> </Setter.Value> </Setter> </Style> </dataPresenter:FieldSettings.EditorStyle> </dataPresenter:FieldSettings> </dataPresenter:Field.Settings> </dataPresenter:UnboundField>
Hello Curious WPF,
I have been investigating into the behavior you are seeing, and I believe the behavior you are seeing could be due to the cells that belong to the UnboundField not having a Value, which is where the XamTextEditor that you are re-templating would pull its value from, and this could be having an effect on the XamMultiColumnComboEditor that you have placed in its template. As such, I would recommend that you ensure that the Cell.Value of the cells belonging to your UnboundField have a Value. You can do this by looping through the Records collection of the XamDataGrid and checking the Cells[<yourFieldIndex>].Value.
It is also worth noting that I can see that you are only using a single column in the XamMultiColumnComboEditor and as such, I am wondering if the built-in XamComboEditor that exists in the same assembly as the XamTextEditor would work better for you in this case? The “WPF-specific” XamComboEditor was built to be used as an editor in the XamDataGrid, and you can use it simply by writing an EditorStyle for XamComboEditor for your UnboundField. This type of editor will also automatically resolve the Cell.Value to a value within the editor, making it much easier to use.
Please let me know if you have any other questions or concerns on this matter.
Hi Andrew,
Thank you for the reply , I have need to use XamMultiColumnComboEditor as it offers search capabilities, the approach that I have taken works without any issues , the issue is when I use the scrollbar , wondering why would the selection changed on the combo is getting fired , which in turn the clearing the existing cell values , I would like to know if there is way to prevent this clearing of data when the vertical scrollbar is used .We have been using IG controls for the past 4+ years , this is the first time we are encountering such an issue .Any help to resolve this would be greatly appreciated as this blocking the release of critical feature.
Regards,
Rajesh
Hello Rajesh,
I have put together a sample project that is heavily based on the sample code that you have provided, but I cannot seem to reproduce the behavior where the XamMultiColumnComboEditor clears as you scroll the grid.
I am attaching the sample project I used to test this. Please test this project on your PC; whether or not it works correctly may help indicate the nature of this problem.
If the project does not work correctly, this indicates either a problem possibly specific to your environment, or a difference in the DLL versions we are using. As you have mentioned you are using version 2014.1, my tests were performed using version 14.1.20141.2283 in Infragistics for WPF 2014.1.
If the project does show the product feature working correctly, this indicates a possible problem in the code of your application. It will help if you can provide a small, isolated sample application that demonstrates the behavior you are seeing.
Or, if this sample project is not an accurate demonstration of what you're trying to do, please feel free to modify it and send it back, or send a small sample project of your own if you have one.
XDGMultiComboDemo.zip
I tried to load the sample which you sent , it didn't seem to work for me.
I'm able to reproduce this issue consistently in a standalone application , the problems seems to stem from the fact whenever we use the scrollbar , each row is trying to reload the itemsource which in-turn is triggering the selectionchanged event , this seems to be an issue only with XamComboEditors, we have around 20 columns with different set of usercontrols like combobox , which are working fine . Please investigate further into this.
below are the snippets from sample app,
Xaml
<igDP:XamDataGrid DataSource="{Binding Path=Data}"> <igDP:XamDataGrid.FieldLayouts> <igDP:FieldLayout> <igDP:FieldLayout.Fields> <igDP:Field Name="name"/> <igDP:UnboundField Name="AvailableProductsList" BindingPath="ProductSelected" Label="Available Products" BindingMode="TwoWay"> <igDP:UnboundField.Settings> <igDP:FieldSettings> <igDP:FieldSettings.EditorStyle> <Style TargetType="{x:Type igEditors:XamComboEditor}"> <Setter Property="ItemsSource" Value="{Binding DataItem.Products}"/> <Setter Property="SelectedItem" Value="{Binding DataItem.ProductSelected}"/> </Style> </igDP:FieldSettings.EditorStyle> </igDP:FieldSettings> </igDP:UnboundField.Settings> </igDP:UnboundField> <igDP:Field Name="salary"/> <igDP:Field Name="email"/> </igDP:FieldLayout.Fields> </igDP:FieldLayout> </igDP:XamDataGrid.FieldLayouts> </igDP:XamDataGrid>
Code Behind
using Infragistics.Windows.DataPresenter;using Infragistics.Windows.Editors;using System;using System.Collections.Generic;using System.Collections.ObjectModel;using System.ComponentModel;using System.Linq;using System.Text;using System.Windows;using System.Windows.Controls;using System.Windows.Data;using System.Windows.Documents;using System.Windows.Input;using System.Windows.Media;using System.Windows.Media.Imaging;using System.Windows.Navigation;using System.Windows.Shapes;using Infragistics.Windows.DataPresenter.Events;
namespace SelectedIndexChange{ /// <summary> /// Interaction logic for MainWindow.xaml /// </summary> public partial class MainWindow : Window { public SampleData Data { get; set; }
public MainWindow() { InitializeComponent(); Data = new SampleData(); this.DataContext = this; } }
public class SampleDataItem : INotifyPropertyChanged { #region INotifyPropertyChanged Implementation public event PropertyChangedEventHandler PropertyChanged; protected void OnPropertyChanged(string propertyName) { if (PropertyChanged != null) PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); } #endregion
public string name { get; set; } public string department { get; set; } public double salary { get; set; } public string email { get; set; }
public string UniId { get; set; }
public ObservableCollection<string> Products { get; set; } private int _productsSelectedIndex; public int ProductsSelectedIndex { get { return _productsSelectedIndex; } set { _productsSelectedIndex = value; OnPropertyChanged("ProductsSelectedIndex"); } }
private string _productSelected; public string ProductSelected { get { return _productSelected; } set { _productSelected = value; OnPropertyChanged("ProductSelected"); } } }
public class SampleData : ObservableCollection<SampleDataItem> { public SampleData() { var products = new ObservableCollection<string> { "product 1", "product 2", "product 3", };
var products1 = new ObservableCollection<string> { "product 4", "product 5", "product 6", };
var products3 = new ObservableCollection<string> { "product 7", "product 8", "product 9", };
var products4 = new ObservableCollection<string> { "product 10", "product 11", "product 12", };
Add(new SampleDataItem {UniId = "1:" +Guid.NewGuid().ToString(), name = "Joe", department = "Sales", salary = 70000.0, email = "joe@email.com", Products = products, ProductSelected = products[1] }); Add(new SampleDataItem { UniId = "2:" + Guid.NewGuid().ToString(), name = "Mary", department = "Engineering", salary = 71000.0, email = "mary@email.com", Products = products, ProductSelected = products[2] }); Add(new SampleDataItem { UniId = "3:" + Guid.NewGuid().ToString(), name = "Jim", department = "Sales", salary = 72000.0, email = "jim@email.com", Products = products, ProductSelected = products[0] });
Add(new SampleDataItem { UniId = "4:" + Guid.NewGuid().ToString(), name = "Joe", department = "Sales", salary = 70000.0, email = "joe@email.com", Products = products, ProductSelected = products1[1] }); Add(new SampleDataItem { UniId = "5:" + Guid.NewGuid().ToString(), name = "Mary", department = "Engineering", salary = 71000.0, email = "mary@email.com", Products = products, ProductSelected = products1[2] }); Add(new SampleDataItem { UniId = "6:" + Guid.NewGuid().ToString(), name = "Jim", department = "Sales", salary = 72000.0, email = "jim@email.com", Products = products, ProductSelected = products1[0] });
Add(new SampleDataItem { UniId = "7:" + Guid.NewGuid().ToString(), name = "Joe", department = "Sales", salary = 70000.0, email = "joe@email.com", Products = products, ProductSelected = products3[1] }); Add(new SampleDataItem { UniId = "8:" + Guid.NewGuid().ToString(), name = "Mary", department = "Engineering", salary = 71000.0, email = "mary@email.com", Products = products, ProductSelected = products3[2] }); Add(new SampleDataItem { UniId = "9:" + Guid.NewGuid().ToString(), name = "Jim", department = "Sales", salary = 72000.0, email = "jim@email.com", Products = products, ProductSelected = products3[0] });
Add(new SampleDataItem { UniId = "10:" + Guid.NewGuid().ToString(), name = "Joe", department = "Sales", salary = 70000.0, email = "joe@email.com", Products = products, ProductSelected = products4[1] }); Add(new SampleDataItem { UniId = "11:" + Guid.NewGuid().ToString(), name = "Mary", department = "Engineering", salary = 71000.0, email = "mary@email.com", Products = products, ProductSelected = products4[2] }); Add(new SampleDataItem { UniId = "12:" + Guid.NewGuid().ToString(), name = "Jim", department = "Sales", salary = 72000.0, email = "jim@email.com", Products = products, ProductSelected = products4[0] }); } }}
Thank you for your update. Out of curiosity, what issues did you have running the original sample project I provided you?
With the above asked, it is worth noting that I have created a new sample project with the code that you have provided along with a couple of small changes. For example, in the new sample code that you have provided, there is no reason to use an UnboundField because the BindingPath of “ProductSelected” exists directly on your data item, and so you can just add a Field with its Name set to “ProductSelected” to auto-fill the cell values of that column. You also do not need to set the “SelectedItem” because the XamComboEditor is designed to work as an editor in the XamDataGrid and will automatically resolve the cell value to a value in the combo if it exists.
By making these changes, I cannot see the behavior you are seeing where scrolling clears the value of the cell. I have again created my sample against version 14.1.20141.2283 as this is the latest version of Infragistics WPF 2014.1. I am attaching the sample here.
XDGComboDemo.zip