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. Image for the cookie policy date

ExcelFilter Relation nor working

Hello,

I need a little bit help. I use Entity Framework.
I have a table with ORDERS and inside a column with a UserID. I load the table with:

using (DiBeMaEntities db = new DiBeMaEntities())
            {
                orderBindingSource.DataSource = db.order.ToList();
                userBindingSource.DataSource = db.users.toList();
            }

I have a second table with users (UserId and Name) and I would replace the UserId with the Name:

gridGroupingControl1.TableDescriptor.Columns["User"].Appearance.AnyRecordFieldCell.CellType = "GridListControl";

        private void gridGroupingControl1_QueryCellStyleInfo(object sender, GridTableCellStyleInfoEventArgs e)
        {
            if (e.TableCellIdentity.TableCellType == GridTableCellType.AlternateRecordFieldCell || e.TableCellIdentity.TableCellType == GridTableCellType.RecordFieldCell)
            {
                if (e.TableCellIdentity.Column != null && (e.TableCellIdentity.Column.MappingName == "CreateUser" || e.TableCellIdentity.Column.MappingName == "EditUser"))
                {
                    e.Style.DataSource = userBindingSource.DataSource;
                    e.Style.DisplayMember = "Lastname";
                    e.Style.ValueMember = "UserId";
                }
            }
        }

This is working, but I use the Excel-Filter and there I see only the UserId. How can I change this?

I try this instead of the code above, but it is not working.
gridGroupingControl1.TableDescriptor.Columns["CreateUser"].Appearance.AnyRecordFieldCell.DataSource = userBindingSource.DataSource;
gridGroupingControl1.TableDescriptor.Columns["CreateUser"].Appearance.AnyRecordFieldCell.DisplayMember = "Lastname";
gridGroupingControl1.TableDescriptor.Columns["CreateUser"].Appearance.AnyRecordFieldCell.ValueMember = "UserId";
gridGroupingControl1.TableDescriptor.Columns["CreateUser"].Appearance.ColumnHeaderCell.DataSource = userBindingSource.DataSource;
gridGroupingControl1.TableDescriptor.Columns["CreateUser"].Appearance.ColumnHeaderCell.DisplayMember = "Lastname";
gridGroupingControl1.TableDescriptor.Columns["CreateUser"].Appearance.ColumnHeaderCell.ValueMember = "UserId";

And my next question. Is it possible to remove the DropDownButton in the GridListControl in the User-Cell?

Thanks for your support
BR Thomas


1 Reply

AR Amal Raj U Syncfusion Team January 16, 2017 06:25 AM UTC

Hi Thomas, 

Thanks for using Syncfusion products. 

 
 
 
 
 
 I use the Excel-Filter and there I see only the UserId. How can I change this? 
We are able to understand your scenario. In order to filter by display member of the column in GridExcelFilter then the display member and value member must be defined through default styles, since we do not have support for filter by display member while using QueryCellStyleInfo events. Please make use of the below code, 

Code Example 
//to enable GridExcelFilter filter by display member. 
this.gridGroupingControl1.TableDescriptor.Columns["User"].Appearance.AnyRecordFieldCell.CellType = GridCellTypeName.GridListControl; 
this.gridGroupingControl1.TableDescriptor.Columns["User"].Appearance.AnyRecordFieldCell.DataSource = childTable; 
this.gridGroupingControl1.TableDescriptor.Columns["User"].Appearance.AnyRecordFieldCell.DisplayMember = "LastName"
this.gridGroupingControl1.TableDescriptor.Columns["User"].Appearance.AnyRecordFieldCell.ValueMember = "UserID"
 


Is it possible to remove the DropDownButton in the GridListControl in the User-Cell? 
In order to disable the DropDownButton in the GridListControl in cells, then the ShowButtons property can be used. Please make use of the below code, 
 
Code Example 
//to disable the dropdown buttons. 
this.gridGroupingControl1.TableDescriptor.Columns["User"].Appearance.AnyRecordFieldCell.ShowButtons = GridShowButtons.Hide; 
 


Sample Link 

 

Regards, 
Amal Raj U. 


Loader.
Up arrow icon