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

[Solved] set selectitem before dataloaded event

3 Answers 79 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Jonam
Top achievements
Rank 1
Jonam asked on 20 Aug 2010, 06:37 PM
Hello,

my problem is the following. I set a radGridView.ItemsSource with an List<object>. But i can't set the selectedItem untill the dataloaded event is fired. Is there a way to manual fire the dataloaded event.

The reason why want to do this is because i have chained 6 grids together with a filter event. The selected row on grid 1 is the filter for grid2. The selected row on grid 2 is the filter for grid 3 etc.

this is the function that supplies the filtering. This works fine but just not untill the second grid has opened once. Help!

public void SetFilterParentId(int id, string filterDescription)
{
    CurrentFilter = filterDescription;
    radGridView1.FilterDescriptors.Clear();
    radGridView1.FilterDescriptors.Add(
        new FilterDescriptor()
        {
            IsCaseSensitive = false,
            Member = "AccountLevel2TotalId",
            Operator = FilterOperator.IsEqualTo,
            Value = id
        });
    if ((radGridView1.Items.Count > 0) && (radGridView1.SelectedItem == null))
    {
        radGridView1.SelectedItem = radGridView1.Items[0];
    }
    else
    {
        AccountLevel3Total item = (AccountLevel3Total)radGridView1.SelectedItem;
        if (item == null)
        {
            {
                if (OnFilterChanged != null)
                    OnFilterChanged(this, new FilterChangedEventArgs(-1, filterDescription + Definitions.FILTER_SEPERATOR + Definitions.NO_FILTER));
            }
        }
        //else
        //    if (OnFilterChanged != null)
        //        OnFilterChanged(this, new FilterChangedEventArgs(item.Id));
    }
}

3 Answers, 1 is accepted

Sort by
0
Milan
Telerik team
answered on 23 Aug 2010, 12:06 PM
Hello Jonam,

This is a know issue which we expect to fix for the next official release. 

For the time being you can use the following workaround: Once a grid view is loaded (shown) you will be able to set its SelectedItem at any time (not only in the DataLoaded event). Once your application is Loaded you can wait a predefined amount of time, say 200 milliseconds, to allow all grids to load and setup the initial states of all 6 grids. 

Hope this helps.

Kind regards,
Milan
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
Jonam
Top achievements
Rank 1
answered on 24 Aug 2010, 09:25 AM
Hello Milan,

I can set the grid after it is loaded . "Once a grid view is loaded (shown)". But my grid is loaded but not yet shown? Is their way a simulate a shown but not actually show the form?

Because i can set the selectItem. This works after the shown.

The problem is grid6 depands on grid5. Grid 5 depands on grid4. Grid 4 depands on grid 3 etc.

If i go directly to grid6 the show event is raised but grid6 never received anything from grid5 because this one isn't show before. I can wait for 200 milliseconds but still the grid isn't showned. Are their any solutions to this problem?

kind regards,

Jonam
0
Milan
Telerik team
answered on 24 Aug 2010, 10:14 AM
Hi Jonam,

Another possible solution is to set the selected item of the respective grid using Dispatcher.BeginInvoke which will be executed a bit later and this could work in your application.


Kind regards,
Milan
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
Tags
GridView
Asked by
Jonam
Top achievements
Rank 1
Answers by
Milan
Telerik team
Jonam
Top achievements
Rank 1
Share this question
or