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

ItemSource changes, RadGrid doesnt update

4 Answers 162 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Thomas Howard
Top achievements
Rank 1
Thomas Howard asked on 23 Jun 2010, 07:46 AM
Straight to the point..

I have two RadGridView objects in separate RadTiles. The first is populated on page load and does not change. The second grid shows data depending on what is selected in the first grid.

When the CurrentCellChanged event is fired from the first grid, it should change the ItemSource of the second grid but the second grid doesn't change at all.

I'm sure I have missed a couple of lines of code somewhere, if someone could point out where I am going wrong, I would be very grateful :)

    /*This is the codebehind for the page containing the first grid*/ 
    public partial class Panel3 : RadPage 
    { 
        public Panel3() 
        { 
            InitializeComponent(); 
            //Get the list of sites 
            var proxy = new ServiceReference1.Service1Client(); 
            proxy.GetSitesCompleted += new EventHandler<ServiceReference1.GetSitesCompletedEventArgs>(proxy_GetSitesCompleted); 
            proxy.GetSitesAsync(); 
        } 
 
        void proxy_GetSitesCompleted(object sender, ServiceReference1.GetSitesCompletedEventArgs e) 
        { 
            //Put the list of sites into the grid 
            SiteGrid.ItemsSource = e.Result; 
        } 
 
        private void SiteGrid_CurrentCellChanged(object sender, GridViewCurrentCellChangedEventArgs e) 
        { 
            //Get the value of the selected cell 
            string SelectedSite = SiteGrid.CurrentCell.Value.ToString(); 
            //Query using the value of the selected cell 
            var proxy = new ServiceReference1.Service1Client(); 
            proxy.SelectedZoneCompleted += new EventHandler<ServiceReference1.SelectedZoneCompletedEventArgs>(proxy_SelectedZoneCompleted); 
            proxy.SelectedZoneAsync(SelectedSite); 
        } 
 
        void proxy_SelectedZoneCompleted(object sender, ServiceReference1.SelectedZoneCompletedEventArgs e) 
        { 
            //Call some code from the other page.... 
            //MessageBox.Show(e.Result.ToString()); 
            new Panel4(e.Result); 
        } 
 
    } 

    /*This is the codebehind for the page containing the second grid*/ 
    public partial class Panel4 : RadPage 
    { 
        public Panel4() 
        { 
            InitializeComponent(); 
            //This will load some default data 
            GetGridData(1120009); 
        } 
        public Panel4(int site) 
        { 
            InitializeComponent(); 
            //This is called from Panel3 
            GetGridData(site); 
        } 
 
        void GetGridData(int site) 
        { 
            //Get Data for the grid 
            var proxy = new ServiceReference1.Service1Client(); 
            proxy.GetCountsCompleted += new EventHandler<ServiceReference1.GetCountsCompletedEventArgs>(proxy_GetCountsCompleted); 
            proxy.GetCountsAsync(site, DateTime.Today.AddDays(-15), DateTime.Today.AddDays(-14), DateTime.Now.AddHours(-2), DateTime.Now); 
        } 
        void proxy_GetCountsCompleted(object sender, ServiceReference1.GetCountsCompletedEventArgs e) 
        { 
            //Change the ItemSource 
            Grid1.ItemsSource = e.Result; 
        } 
    } 

4 Answers, 1 is accepted

Sort by
0
Maya
Telerik team
answered on 28 Jun 2010, 01:56 PM
Hi Thomas Howard,

 
You may try to add the second element - Panel4 into the visual tree. For example, if the basic item is Panel3 and it is defined as x:Name="Panel3", the child should be appended as:

this.Panel3.Children.Add(new Panel4());

I hope that helps, but in case it is not applicable in your application, please give us more details about the settings and the requirements of the project.

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
Thomas Howard
Top achievements
Rank 1
answered on 29 Jun 2010, 04:47 AM
Thanks for your reply Maya,

I probably should have left some more information about my application in my original post..

The RadTiles are declared in my xaml like this:
<Controls:RadTileView Grid.Column="1" Grid.Row="1" Grid.RowSpan="2" Grid.ColumnSpan="3"
            <Controls:RadTileViewItem x:Name="Tile1"
                <EDM002:Panel1/> 
            </Controls:RadTileViewItem> 
            <Controls:RadTileViewItem x:Name="Tile2"
                <EDM002:Panel2/> 
            </Controls:RadTileViewItem> 
            <Controls:RadTileViewItem x:Name="Tile3"
                <EDM002:Panel3/> 
            </Controls:RadTileViewItem> 
            <Controls:RadTileViewItem x:Name="Tile4"
                <EDM002:Panel4/> 
            </Controls:RadTileViewItem> 
</Controls:RadTileView> 
I opted to keep the contents of each Tile in its own separate page to make the project easier to handle but I'm starting to think that this is the problem.

Is there a way to reload a RadTile without reloading the rest of the page?
0
Accepted
Maya
Telerik team
answered on 01 Jul 2010, 04:24 PM
Hi Thomas Howard,

I am sending you a sample project implementing the custom logic you need for your application.
Here the MainPage.xaml is responsible for the coordination between the two RadTileViewItems. Panel3 is the one populated with data on the page loading. It has a Property responsible for the SelectedItem in the first grid - in this case it is the CurrentClub. Furthermore, it is using the SelectionChanged event that executes the custom event CurrentClubChanged created in Panel4.

private void clubsGrid_SelectionChanged(object sender, Telerik.Windows.Controls.SelectionChangeEventArgs e)
    {
        if (this.CurrentClubChanged != null)
        {
            this.CurrentClubChanged(this, EventArgs.Empty);
        }
    }

In Panel3 is added a method LoadPlayersForClub:
public void LoadPlayersForClub(Club club)
        {
            if (club == null)
            {
                this.playersGrid.ItemsSource = null;
            }
            else
            {
                this.playersGrid.ItemsSource = club.Players;
            }
        }

This is the place for loading your data for the grid.


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
Thomas Howard
Top achievements
Rank 1
answered on 02 Jul 2010, 03:36 AM
Exactly what i needed, Thanks!
Tags
GridView
Asked by
Thomas Howard
Top achievements
Rank 1
Answers by
Maya
Telerik team
Thomas Howard
Top achievements
Rank 1
Share this question
or