BoldDeskBoldDesk is now live on Product Hunt with a special offer: 50% off all plans. Let's grow together! Support us.
Hi,
perhaps there exists a solution for my Problem.
http://www.syncfusion.com/support/forums/grid-wpf/106267/Column-combobox-itemsource
but this sample download works not.
Could you please reactivate also other examples. many links to sample files doesn't work.
If it's impossible, would you mind to offer a sample with a Combobox column .
The itemssource depends on the Content of the row
Cheers
Andreas Löwe
Hi Andreas,
Sorry for the delay caused.
We can set dynamic Items Source for Combo Box in GridDatacontrol by using QueryCellInfo event. Here, you can retrieve the Particular record from its CellIdentity and also you can check for the Particular column using its mapping name and can assign your dynamic items source to that particular cell as in the following code snippet.
Code Snippet: void Model_QueryCellInfo(object sender, GridQueryCellInfoEventArgs e) { var style = e.Style as GridDataStyleInfo; var cellidentity = style.CellIdentity; if (cellidentity != null && cellidentity.Record != null && cellidentity.Column.MappingName == "State") { //Here based on the cellidentity.Record, you can apply items source var Record = cellidentity.Record as Model; var item = Record.Country;
if (item.ToString().Contains("USA")) { e.Style.ItemsSource = new USStateRepository(); }
e.Style.CellValue = ((ObservableCollection<String>)e.Style.ItemsSource)[0]; } |
We have also prepared a sample based on this and attached it in the following location.
Sample: http://www.syncfusion.com/downloads/Support/DirectTrac/110535/Country%20correct605559276.zip
Regarding the “Dead Links in forum”
Due to a server failure at one of our hosting sites, the file you are looking for is not available. We are making every effort to retrieve this file and other files that are unavailable as a result of this outage. We regret this inconvenience. We will inform you when the file has been recovered. If you need any other sample from Forums then please let us know the Forum link or your requirement, we will prepare a sample based on your requirement and update you with the details.
Regards,
Divya.
void Model_QueryCellInfo(object sender, GridQueryCellInfoEventArgs e)
{
var style = e.Style as GridDataStyleInfo;
var cellidentity = style.CellIdentity;
if (cellidentity != null && cellidentity.Record != null && cellidentity.Column.MappingName == "State")
{
var Record = cellidentity.Record as Model;
var item = Record.Country;
if (item.ToString().Contains("USA"))
{
e.Style.ItemsSource = new USStateRepository();
}
else if (item.ToString().Contains("Australia"))
{
e.Style.ItemsSource = new AusStateRepository();
}
else if (item.ToString().Contains("India"))
{
e.Style.ItemsSource = new IndStateRepository();
}
var itemsource = e.Style.ItemsSource as ObservableCollection<string>;
if(!(itemsource.Contains(e.Style.CellValue.ToString())))
e.Style.CellValue = ((ObservableCollection<String>)e.Style.ItemsSource)[0];
}
} |