Hi,
thank you for this reply and your example.
Yes, probably your suspections are correct.
In fact, my need is not to change the ItemsSource for each different row in the grid.
My need is to have the possibility, having a unique global list for the ItemSource, to filter its content according to the current row (and relative binded record) and let the user be able to select, for each different record, only a subset (filtered) of the whole global ItemSource collection.
It is clearer now? Thank you.
Have a nice week end.
Silvio S.
Dear Muthukumar
I have another different idea, if it is possible.
Surely when the ComboBox is opened an SfDataGrid is displayed.
So, is it possible to set View.Filter Predicate property of this SfDataGrid in order to implement in this passed method all my filtering related to the current grid selection?
If it is, can you show me how and where to set it ?
Thank you.
Silvio
<local:GridComboBoxColumnExt DisplayMemberPath="CityName"
MappingName="CityID"
SelectedValuePath="CityID">
<local:GridComboBoxColumnExt.ItemsSourceSelectorSelector>
<local:ItemsSourceSelectorSelector/>
</local:GridComboBoxColumnExt.ItemsSourceSelectorSelector>
</local:GridComboBoxColumnExt>
|
public class ItemsSourceSelectorSelector : IItemsSourceSelector
{
public IEnumerable GetItemsSource(object record, object dataContext)
{
if (record == null)
return null;
//write ItemSource based on your record.
}
}
|
Dear Muthukumar,
the last example you have proposed me should be similar to what I'd like to obtain.
By I don't like to use GridComboBoxColumn in my SfDataGrid.
I'd like to use, instead, a GridMultiColumnDropDownList column that let me to show to the user more columns for each record.
It was for this reason that I sugested you if it was possible to use View.Filter Predicate, since it seems to me that this column type uses an SfDataGrid to display the popup where the user selects a record.
So, is it possible to have an example similar to the last one when a GridMultiColumnDropDownList column is used ?
Thank you,
Silvio
<local:GridMultiColumnExt DisplayMember="CityName" ItemsSource="{Binding OrderList}"
MappingName="CityID" ValueMember="CityID" >
<local:GridMultiColumnExt.ItemsSourceSelectorSelector>
<local:ItemsSourceSelectorSelector/>
</local:GridMultiColumnExt.ItemsSourceSelectorSelector>
</local:GridMultiColumnExt>
|
public class GridCellMultiComboBoxRendererExt : GridCellMultiColumnDropDownRenderer
{
public GridCellMultiComboBoxRendererExt() : base()
{ }
public override bool CanUpdateBinding(GridColumn column)
{
return true;
}
public override void OnInitializeEditElement(DataColumnBase dataColumn, SfMultiColumnDropDownControl uiElement, object dataContext)
{
var customColumn = (GridMultiColumnExt)dataColumn.GridColumn;
//Setting ItemsSource for GridComboBoxColumn
if (customColumn != null && customColumn.ItemsSourceSelectorSelector != null)
{
object value = customColumn.ItemsSourceSelectorSelector.GetItemsSource(dataContext, DataGrid.DataContext);
customColumn.ItemsSource = value as IEnumerable;
}
base.OnInitializeEditElement(dataColumn, uiElement, dataContext);
}
}
public class ItemsSourceSelectorSelector : IItemsSourceSelector
{
public IEnumerable GetItemsSource(object record, object dataContext)
{
if (record == null)
return null;
//write ItemSource based on your record.
}
} |