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: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

GridMultiColumnDropDownList allow values not in list

Thread ID:

Created:

Updated:

Platform:

Replies:

145420 Jun 20,2019 02:34 PM UTC Jul 1,2019 08:40 AM UTC WPF 8
loading
Tags: SfDataGrid
Ondrej Svoboda
Asked On June 20, 2019 02:34 PM UTC

Hi,
is there a way how to use values not GridMultiColumnDropDownList's list?

My scenario is that drop down list contains only most used values - user can choose from them or enter other value by hand. 
Right now when cell contains a value not in GridMultiColumnDropDownList's list blank value is displayed and I also didnt find a way how to enter value not in list.

Thanks
Ondřej Svoboda

Shobika Palani [Syncfusion]
Replied On June 21, 2019 11:42 AM UTC

Hi Ondrej, 

Thank you for contacting Syncfusion Support. 

We have analyzed your query to enter a value that is not in the list of GridMultiDropDownList.  

Could you please let us know whether your requirement is to have same itemsSource for the rows in multi dropdown column or to load different itemssource for different rows as like ItemsSourceSelector behavior in GridComboBoxColumn? It will helps us to investigate further and provide appropriate solution at earlier. 

Regards, 
Shobika. 


Ondrej Svoboda
Replied On June 21, 2019 12:04 PM UTC

Hi,
I will have same items source for all the rows.

Regards
Ondřej

Shobika Palani [Syncfusion]
Replied On June 24, 2019 04:54 PM UTC

Hi Ondrej, 

Thanks for your update. 

We are currently analyzing the feasibility to achieve your requirement. We will update you with more details on 26th June,2019. 

We will appreciate your patience. 

Regards, 
Shobika. 


Farjana Parveen Ayubb [Syncfusion]
Replied On June 26, 2019 09:34 AM UTC

Hi Ondrej, 
  
Thanks for your patience. 
  
We have analyzed your query to a value to GridMultiColumnDropDownList that is not in underlying collection. You can achieve this requirement by using CustomMultiColumnDropDownControl and CustomMultiColumnDropDownRenderer. Please refer to the below code snippet 
  
this.Grid.CellRenderers.Remove("MultiColumnDropDown"); 
this.Grid.CellRenderers.Add("MultiColumnDropDown"new CustomMultiColumnDropDownRenderer()); 
  
  
public class CustomMultiColumnDropDownRenderer: GridCellMultiColumnDropDownRenderer 
    { 
        protected override SfMultiColumnDropDownControl OnCreateEditUIElement() 
        { 
            return new CustomMultiColumnDropDownControl(this.DataGrid); 
        } 
  
        protected override bool ShouldGridTryToHandleKeyDown(KeyEventArgs e) 
        {            
            if (e.Key == Key.Enter) 
            { 
                var multiDropDown = (this.CurrentCellRendererElement as CustomMultiColumnDropDownControl); 
                multiDropDown.AddItem(multiDropDown); 
            } 
            return base.ShouldGridTryToHandleKeyDown(e); 
        } 
    } 
  
    public class CustomMultiColumnDropDownControl : SfMultiColumnDropDownControl 
    { 
        SfDataGrid DataGrid; 
        public CustomMultiColumnDropDownControl(SfDataGrid dataGrid) : base() 
        { 
            DataGrid = dataGrid; 
        } 
        public override void OnApplyTemplate() 
        { 
            Editor = GetTemplateChild("PART_TextBox"as TextBox; 
            if (Editor != null) 
                Editor.LostFocus += Editor_LostFocus; 
            base.OnApplyTemplate(); 
  
        } 
        private void Editor_LostFocus(object sender, RoutedEventArgs e) 
        { 
            if (!string.IsNullOrEmpty(SearchText)) 
            { 
                AddItem(this); 
            } 
        } 
  
        internal void AddItem(SfMultiColumnDropDownControl multiDropDown) 
        { 
            var textBox = multiDropDown.GetType().GetProperty("Editor", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance).GetValue(multiDropDown); 
            var newValue = textBox != null ? (textBox as TextBox).Text : null; 
            var underlyingItems = ((multiDropDown as CustomMultiColumnDropDownControl).DataGrid.DataContext as ViewModel).ProductList; 
  
            if (underlyingItems != null) 
            { 
                bool newRecord = underlyingItems.Any(x => x.Code == newValue.ToString()); 
                if (!newRecord) 
                { 
                    underlyingItems.Add(new ProductInfo() { Code = newValue.ToString(), ID = underlyingItems.Count + 1 }); 
                    multiDropDown.SelectedItem = underlyingItems.Last(); 
                } 
            } 
        } 
    } 
  
Please find sample for the same from the link below 
  
Sample Link: 
  
Please let us know, if you require further assistance on this. 
  
Regards, 
Farjana Parveen A. 


Ondrej Svoboda
Replied On June 27, 2019 11:14 AM UTC

Hi,
thanks, I will have a look on it.
In your sample project you have a reference to Syncfusion.SampleLayout - can I get this dll as nuget package like the rest, or I need to install the whole WPF package?

Ondřej

Farjana Parveen Ayubb [Syncfusion]
Replied On June 28, 2019 05:44 AM UTC

Hi Ondrej, 
  
We regret for the inconvenience caused. We have SampleLayout assembly for internal purpose to showcase the samples in SampleBrowser. So we do not publish Nuget package for that assembly. Instead, we have modified the sample provided in our previous update excluding the usage of SampleLayout assembly. Please refer to sample in the link below 
  
Sample Link: 
  
Please let us know, if you require further assistance on this. 
  
Regards, 
Farjana Parveen A 


Ondrej Svoboda
Replied On June 28, 2019 11:10 AM UTC

Hi,
thanks, it is working like I need, except one thing. Please see attached modified sample.

OrderInfo with OrderID = 2 has ProductCode = "bike". But this ProductCode is not in ProductList (deliberately). When you run it empty value is shown in the cell.
Is there a way how to display this value even if it is not in the list?

Thanks

Ondřej


Attachment: GridMultiColumnDropDownDemo94181646_ded3559b.zip

Farjana Parveen Ayubb [Syncfusion]
Replied On July 1, 2019 08:40 AM UTC

Hi Ondrej, 
 
We have analyzed your query to display the value even if it is not in the list on initial loading itself in GridMultiColumnDropDownList. This requirement can be achieved by overriding OnInitializeDisplayElement in CustomMultiColumnDropDownRenderer.  
 
Please refer to the below code snippet 
 
public class CustomMultiColumnDropDownRenderer : GridCellMultiColumnDropDownRenderer 
       { 
              protected override SfMultiColumnDropDownControl OnCreateEditUIElement() 
              { 
                     return newCustomMultiColumnDropDownControl(DataGrid); 
              } 
  
        public override voidOnInitializeDisplayElement(DataColumnBase dataColumn, TextBlock uiElement, object dataContext) 
        { 
            var gridColumn = dataColumn.GridColumn asGridMultiColumnDropDownList; 
            var itemsSource = gridColumn.ItemsSource asObservableCollection<ProductInfo>; 
            var record = dataContext as OrderInfo; 
            if (!(itemsSource.Any(info => info.Code == record.ProductCode))) 
                itemsSource.Add(new ProductInfo() { Code = record.ProductCode }); 
  
            base.OnInitializeDisplayElement(dataColumn, uiElement, dataContext); 
        } 
        protected override boolShouldGridTryToHandleKeyDown(KeyEventArgs e) 
              { 
                     if (e.Key == Key.Enter) 
                     { 
                           var multiDropDown = (CurrentCellRendererElement asCustomMultiColumnDropDownControl); 
                          multiDropDown.AddItem(multiDropDown); 
                     } 
                     returnbase.ShouldGridTryToHandleKeyDown(e); 
              } 
       } 


 
Also please find the modified sample from the link below 
 
Sample Link: 
 
Please let us know, if you require further assistance on this. 
 
Regards,
Farjana Parveen 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

Live Chat Icon For mobile
Live Chat Icon