Regarding GridComboboxColumn Column Type

 [1] How to Manage GridComboboxColumn Selected Index Change Event ?
[2] Getting Error when I type value which doesn't exists in Combo box List
[3] Getting Error when I type value & press down key trying to select value which doesn't exists in Combo box List.
[4] Enter key creating new row, which is doesn't want.
[5] Need typed text which doesn't exists in Combo box List.



8 Replies

AV Avinash September 6, 2018 07:44 AM UTC

Kindly provide Update


AA Arulraj A Syncfusion Team September 6, 2018 09:29 AM UTC

Hi Avinash, 

Thanks for contacting Syncfusion support. 

Query 
Solution 
How to Manage GridComboboxColumn Selected Index Change Event ? 
You can make use of the SfDataGrid.CellComboBoxSelectionChanged, in which the event argument contains SelectedIndex property. Please refer to the following code example  

Code Example : 
this.sfDataGrid1.CellComboBoxSelectionChanged += sfDataGrid1_CellComboBoxSelectionChanged; 
 
void sfDataGrid1_CellComboBoxSelectionChanged(object sender, CellComboBoxSelectionChangedEventArgs e) 
{ 
    if (e.SelectedIndex == 1) 
    { 
        //Do your customizations here. 
    } 
} 
 
Enter key creating new row, which doesn't want. 
We suspect that your requirement is to avoid creating a new row when enter key is pressed on the GridComboBoxColumn cell of the AddNewRow. This can be avoided by using the SfDataGrid.RowValidating event. 

Please refer to the following code example. 

Code Example :  
 
this.sfDataGrid1.RowValidating += sfDataGrid1_RowValidating; 
 
void sfDataGrid1_RowValidating(object sender, RowValidatingEventArgs e) 
{ 
    if(e.DataRow.RowIndex == this.sfDataGrid1.GetAddNewRowIndex()) 
    { 
        if (this.sfDataGrid1.CurrentCell.Column is GridComboBoxColumn) 
            e.IsValid = false; 
    } 
} 
 
 
Getting Error when I type value which doesn't exists in Combo box List 

Getting Error when I type value & press down key trying to select value which doesn't exists in Combo box List. 

Need typed text which doesn't exists in Combo box List. 
SfDataGrid doesn’t have support to accept the typed value which doesn’t exist in the ComboBox list. It is the cause for the error. But we can provide a workaround to achieve this requirement by adding the newly typed value to the ComboBox list using the SfDataGrid.CurrentCellValidating event. Please refer to the following code example. 

Code Example: 
 
this.sfDataGrid1.CurrentCellValidating += sfDataGrid1_CurrentCellValidating; 
 
void sfDataGrid1_CurrentCellValidating(object sender, CurrentCellValidatingEventArgs e) 
{ 
    if (this.sfDataGrid1.CurrentCell.Column is GridComboBoxColumn && this.sfDataGrid1.CurrentCell.CellRenderer.CurrentCellRendererElement != null) 
    { 
        var shipCityName = this.sfDataGrid1.CurrentCell.CellRenderer.CurrentCellRendererElement.Text; 
       var shipCityDetails = orderInfo.ShipCityDetails.FirstOrDefault(city => city.ShipCityName == shipCityName); 
 
        if (shipCityDetails == null && !string.IsNullOrEmpty(this.sfDataGrid1.CurrentCell.CellRenderer.CurrentCellRendererElement.Text)) 
        { 
            shipCityID++; 
            orderInfo.ShipCityDetails.Add(new ShipCityDetails() { ShipCityName = this.sfDataGrid1.CurrentCell.CellRenderer.CurrentCellRendererElement.Text, ShipCityID = shipCityID }); 
        } 
    } 
} 
 
 

Please refer to the sample from the following location. 

Arulraj A 



AV Avinash September 6, 2018 09:42 AM UTC

[1]CurrentCellValidating will work with add new  row ? If no how to deal with below scenario
[2]
Getting Error when I type value which doesn't exists in Combo box List 
     Getting Error when I type value & press down key trying to select value which doesn't exists in Combo box List. 
     Need typed text which doesn't exists in Combo box List.


MA Mohanram Anbukkarasu Syncfusion Team September 6, 2018 12:42 PM UTC

Hi Avinash, 
 
Thanks for your update.  
 
The workaround to achieve these requirements provided using the CurrentCellValidating event will also work for AddNewRow. You can refer to the sample provided in the previous update.   
 
 
 
Regards, 
Mohanram A. 
 



AV Avinash September 7, 2018 05:29 AM UTC

[1] Still Getting Error when I type value & press down key trying to select value which doesn't exists in Combo box List.
      Error is related to index was not in range.
      How to manage it  when user type value which doesn't exists in Combo box List. Error should not be thrown & user can select other value


AA Arulraj A Syncfusion Team September 7, 2018 10:23 AM UTC

Hi Avinash, 

Thanks for your update.  

We have checked the reported scenario and we can’t able to reproduce the issue. It is hard to trace why the error is arising without having a look at the sample.  
Is there any possible way for you to provide us with a sample that shows this issue? or reproduce the issue in the following sample. It will be helpful for us to have a closer look into the problem and resolve it.  

 
Arulraj A 



AV Avinash September 7, 2018 04:20 PM UTC

Error find in your example as well:
System.ArgumentOutOfRangeException: 'Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index'
[1] Steps to generate error type value which is not in list & press key down 2 - 3 times.



AK Adhikesevan Kothandaraman Syncfusion Team September 10, 2018 01:21 PM UTC

Hi Avinash, 

Thanks for contacting Syncfusion support. 

We have analyzed your query “Index out of range exception has been thrown while adding the non-exist data in the ComboBox column”. We validated the reported use case and we have consider your use case. A separate support incident has been created under your account to track the status of this query.  

Please log on to our support website to check for further updates. 

http://www.syncfusion.com/Account/Logon?ReturnUrl=%2fsupport%2fdirecttrac/   

Regards, 

Adhi 


Loader.
Up arrow icon