This is a migrated thread and some comments may be shown as answers.

Set GridViewComboBoxColumn ItemsSource on Got Focus

4 Answers 165 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Ivano
Top achievements
Rank 1
Ivano asked on 25 Sep 2010, 08:45 PM
Hi

I trying to set GridViewComboBoxColumn itemsSource when GotFocus event is fired but it doesn't work.
I ' m using Q2 2010 SP1 libraries and I put

this.AddHandler(RadComboBox.GotFocusEvent, new RoutedEventHandler(comboGotFocus));

in the control constructor while the handler is

void comboGotFocus(object sender, RoutedEventArgs args)
{
    GridViewCell cell = args.OriginalSource as GridViewCell;
    if (cell != null && cell.Column.UniqueName == "RegionId")
    {
        District district = cell.DataContext as District;
        if (district != null && cell.Content is LookupElement)
        {
            string countryId = district.CountryId;
            RadGridView gridView = (RadGridView)this.districtRegistryControl.ChildrenOfType<RadGridView>().First();
            RadComboBox comboBox = (cell.Content as LookupElement).ComboBox;
            if (comboBox != null)
            {
                comboBox.ItemsSource = null;
                if (string.IsNullOrEmpty(countryId) == false)
                    comboBox.ItemsSource = from r in iGasContext.Context.Regions
                                           where r.CountryId == countryId
                                           select r;
                else
                    comboBox.ItemsSource = iGasContext.Context.Regions;
            }
        }
    }
}

Thanks
Ivano

4 Answers, 1 is accepted

Sort by
0
Maya
Telerik team
answered on 28 Sep 2010, 01:56 PM
Hi Ivano,

Please share more details about your exact requirements and the scenario you want to accomplish. Thus I will be able to provide you with an appropriate solution and a sample project if needed.
 

All the best,
Maya
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Ivano
Top achievements
Rank 1
answered on 28 Sep 2010, 02:32 PM
Hi

my need is to fiter GridViewComboBoxColumn items based on another row value (in the example above I have to filter available regions on the selected country); the issue has already been discussed in the forum and there's a proposal in a blog too; but the solution do not suite my needs because I'm using ADO.NET Entity Framework 4.0 and data model is autogenerated and updated by VisualStudio (the proposed solution uses ItemsSourceBinding an ad hoc property of Location class).
So I've tried to manage cell GotFocus event and filter cell ComboBox myself; but filter is never applied and combo box is always empty.
I've prepared a sample project; is there a way to upload it?

Sincerely
Ivano
0
Accepted
Maya
Telerik team
answered on 01 Oct 2010, 01:17 PM
Hello Ivano,

All you need to do is to add a partial class and define the property responsible for the filling up the source of the ComboBox. You may follow up the example in this blog post. In the sample project attached in that article, the correct property is AvailableCountries. As for the handling of the lookup values and their implementation, you may read more here.

Kind regards,
Maya
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Ivano
Top achievements
Rank 1
answered on 01 Oct 2010, 03:18 PM
Hi

thanks very much; I'd forgotten that Entity framework classes are partials.

Sincerely
Ivano
Tags
GridView
Asked by
Ivano
Top achievements
Rank 1
Answers by
Maya
Telerik team
Ivano
Top achievements
Rank 1
Share this question
or