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

Filter combobox

3 Answers 173 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Zensell
Top achievements
Rank 1
Zensell asked on 30 Sep 2010, 11:55 AM
Hi, my grid have two columns: Category and Product. Product column is a GridViewComBoxColumn and I want to filter its dropdown items depending on the category in the same row. How could I achieve this? Thanks.

3 Answers, 1 is accepted

Sort by
0
Martin Vasilev
Telerik team
answered on 05 Oct 2010, 04:29 PM
Hi Zensell,

Thank you for writing.

Please find a sample project as an attachment to this message, which demonstrates how to achieve functionality similar to the described one.

I hope this helps. Let me know if you have any additional questions about this.

Greetings,
Martin Vasilev
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
Zensell
Top achievements
Rank 1
answered on 06 Oct 2010, 10:22 AM
Thanks Martin. I am using Q2 2010 SP1. I have found an issue in that sample project:

1. Change the country of any row. For example, select 'Canada'.
2. Select the last item in the city dropdown in that row. For example, select 'Redeer'.
3. Leave the city cell.

Then the city cell in that row blanks out! Is there a fix for this?
0
Accepted
Emanuel Varga
Top achievements
Rank 1
answered on 07 Oct 2010, 11:35 PM
Hello Zensell,

Please try it with these changes:
void radGridView1_CellEditorInitialized(object sender, GridViewCellEventArgs e)
{
    if (this.radGridView1.CurrentColumn.FieldName == "CityId")
    {
        RadDropDownListEditor listEditor = (RadDropDownListEditor)this.radGridView1.ActiveEditor;
        RadDropDownListEditorElement editorElement = (RadDropDownListEditorElement)listEditor.EditorElement;
        localCities.Clear();
        int currentCountryId = int.Parse(this.radGridView1.CurrentRow.Cells["CountryId"].Value.ToString());
        for (int numberOfCities = 0; numberOfCities < cities.Count; numberOfCities++)
        {
            if (cities[numberOfCities].CountryId == currentCountryId)
            {
                localCities.Add(cities[numberOfCities]);
            }
        }
 
        editorElement.DataSource = localCities;
        radGridView1.CurrentCell.Value = (int)e.Value == -1 ? localCities[0].Id : e.Value;
    }
}

Hope this helps, if you have any other questions or comments, please let me know,

Best Regards,
Emanuel Varga
Tags
GridView
Asked by
Zensell
Top achievements
Rank 1
Answers by
Martin Vasilev
Telerik team
Zensell
Top achievements
Rank 1
Emanuel Varga
Top achievements
Rank 1
Share this question
or