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

[Solved] Load on Demand GridView

13 Answers 1044 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.
armarocha
Top achievements
Rank 2
armarocha asked on 16 Apr 2009, 02:48 PM
Hi,

Im using GridView/FirstLook Sample, and i want load data on demand when i clik expand column, its is possible?

Thanks,
Armando Rocha


13 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 21 Apr 2009, 05:24 AM
Hello Armando,

Generally the grid will always load hierarchical data on demand. Please post a bit more info about your scenario.

All the best,
Vlad
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
armarocha
Top achievements
Rank 2
answered on 21 Apr 2009, 09:03 AM
Hi Vlad,

This is the scenario:

I have a gridview with a list of users that i get Asynchronously from a database sql server 2008. What i want to do is ONLY when i click "+" column, invoke a service that return a collection of items related also from database, like i found in a sample in treeview load on demand.

The question is: There is any event where i can put the code to add  data related only for the user i choose in "+" column?

 

This is how i bind the grid:
In page load:

 

 

        void Page_Loaded(object sender, RoutedEventArgs e)   
        {  
            proxy.GetUsersCompleted += new EventHandler<SLMaps.SLDataService.GetUsersCompletedEventArgs> proxy_GetUsersCompleted);   
            proxy.GetUsersAsync();  
        }  
 
        void proxy_GetUsersCompleted(object sender, SLDataService.GetUsersCompletedEventArgs e)  
        {  
            List<Users> users = new List<Users>();  
            // Prepare Child Table  
            //relation   
            TableRelation relation = new TableRelation();  
            relation.FieldNames.Add(new FieldDescriptorNamePair("IMEI""IMEI"));  
            //definition   
            GridViewTableDefinition definition = new GridViewTableDefinition();  
            definition.AutoGenerateFieldDescriptors = false;  
            GridViewDataColumn column = new GridViewDataColumn();  
            column.DataMemberBinding = new Binding("DataStart");  
            column.DataFormatString = "{0:dd-MM-yyyy HH:mm}";  
            column.HeaderText = "Start";  
            column.IsFilterable = false;  
            definition.FieldDescriptors.Add(column);  
            column = new GridViewDataColumn();  
            column.DataMemberBinding = new Binding("DataStop");  
            column.DataFormatString = "{0:HH:mm}";  
            column.HeaderText = "Stop";  
            column.IsFilterable = false;  
            definition.FieldDescriptors.Add(column);  
            column = new GridViewDataColumn();  
            column.DataMemberBinding = new Binding("Distance");  
            column.HeaderText = "Distance";  
            column.IsFilterable = false;  
            column.Width = new GridLength(4, GridUnitType.Star);  
            definition.FieldDescriptors.Add(column);  
            definition.Relation = relation;  
            RadGridView1.TableDefinition.ChildTableDefinitions.Add(definition);  
            relation.FieldNames.Add(new FieldDescriptorNamePair("IMEI""IMEI"));  
 
            foreach (var user in e.Result)  
            {  
                if (user.LastLat != 0)  
                    users.Add(new Users(user.IMEI, user.Name, user.LastDate, new Location(user.LastLat, user.LastLong)));  
                else 
                    users.Add(new Users(user.IMEI, user.Name, string.Empty, new Location(user.LastLat, user.LastLong)));  
            }  
            RadGridView1.ItemsSource = users.ToList();  
        }  
 
 

 


Best Regards,
Armando Rocha
0
Accepted
Vlad
Telerik team
answered on 22 Apr 2009, 02:49 PM
Hello Armando,

I've attached small example to illustrate you how to achieve your goal.

Let me know how it goes.

Sincerely yours,
Vlad
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
armarocha
Top achievements
Rank 2
answered on 22 Apr 2009, 03:14 PM
Hello Vlad,

Thanks for your sample, this is exactly what I needed.

Best regards,
Armando Rocha
0
armarocha
Top achievements
Rank 2
answered on 24 Apr 2009, 05:05 PM
Hi Vlad,

I have a problem with the scroll on the Customers grid, I expand severals Customers to see the orders, when i scroll down to finish and after scroll again to begining the Event  OrdersGrid_Loaded fire again, even the orders has expanded.

I cant't figure out why its happen. You can try the sample that you sand me and you will see.

Best regards,
Armando Rocha

0
Vlad
Telerik team
answered on 27 Apr 2009, 06:04 AM
Hello Armando,

When you scroll up/down the grid will destroy rows outside of the viewable area and will recreate them when needed.

Best wishes,
Vlad
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
armarocha
Top achievements
Rank 2
answered on 27 Apr 2009, 04:07 PM
Hi Vlad,

Is there any way to avoid this happen? It is very important, because i have a grid inside a stackpanel and when i expand rows i can't show the scroll bar in my stackpanel to view all the rows, i prefer use the scroll in stackpanel instead in the grid. How I solve this issue?
It seems that when i use a grid inside a stack panel its not work very good.

Best regards,
Armando Rocha
0
Stefan Dobrev
Telerik team
answered on 28 Apr 2009, 02:45 PM
Hi armarocha,

You should put your StackPanel in a ScrollViewer in order have the content scrollable as expected:

    <ScrollViewer> 
        <StackPanel x:Name="LayoutRoot" Background="White"
            <telerik:RadGridView x:Name="CustomersGrid" AutoGenerateColumns="False"
                <telerik:RadGridView.Columns> 
                    <telerik:GridViewDataColumn HeaderText="CustomerID" DataMemberBinding="{Binding CustomerID}" /> 
                    <telerik:GridViewDataColumn HeaderText="CompanyName" DataMemberBinding="{Binding CompanyName}" /> 
                    <telerik:GridViewDataColumn HeaderText="ContactName" DataMemberBinding="{Binding ContactName}" /> 
                    <telerik:GridViewDataColumn HeaderText="Country" DataMemberBinding="{Binding Country}" /> 
                    <telerik:GridViewDataColumn HeaderText="City" DataMemberBinding="{Binding City}" /> 
                </telerik:RadGridView.Columns> 
                <telerik:RadGridView.HierarchyChildTemplate> 
                    <DataTemplate> 
                        <telerik:RadGridView x:Name="OrdersGrid" DataContext="{x:Null}" ShowGroupPanel="False" 
                         Loaded="OrdersGrid_Loaded" AutoGenerateColumns="False"
                            <telerik:RadGridView.Columns> 
                                <telerik:GridViewDataColumn HeaderText="OrderID" DataMemberBinding="{Binding OrderID}" /> 
                                <telerik:GridViewDataColumn HeaderText="OrderDate" DataMemberBinding="{Binding OrderDate}" DataFormatString="{}{0:d}" /> 
                                <telerik:GridViewDataColumn HeaderText="Freight" DataMemberBinding="{Binding Freight}" DataFormatString="{}{0:c}" /> 
                                <telerik:GridViewDataColumn HeaderText="ShipAddress" DataMemberBinding="{Binding ShipAddress}" /> 
                                <telerik:GridViewDataColumn HeaderText="ShippedDate" DataMemberBinding="{Binding ShippedDate}" DataFormatString="{}{0:d}" /> 
                            </telerik:RadGridView.Columns> 
                        </telerik:RadGridView> 
                    </DataTemplate> 
                </telerik:RadGridView.HierarchyChildTemplate> 
            </telerik:RadGridView> 
        </StackPanel> 
    </ScrollViewer> 

Hope this helps.

Regards,
Stefan Dobrev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
armarocha
Top achievements
Rank 2
answered on 30 Apr 2009, 01:53 PM
Hi Stefan,

The ScrollViewer not work.

Thanks anyway
Best regards,
Armando Rocha
0
Lawrence
Top achievements
Rank 1
answered on 25 Jun 2009, 01:48 PM
Is it possible if you could change this sample to use RIA in a SL3 environment, while still maintaining the same SL2 controls?
0
Vlad
Telerik team
answered on 25 Jun 2009, 02:34 PM
Hi Lawrence,

Indeed you can use the same approach with SL3 however you will need our SL3 build.

Kind regards,
Vlad
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
UB K
Top achievements
Rank 1
answered on 22 Dec 2009, 08:25 PM
Hi,

Is there a way to achieve the same thing with Visual Studio 2005 (ASP.NET C#) and Oracle 10g?
0
manmohan
Top achievements
Rank 1
answered on 22 Nov 2010, 11:19 PM

Hello Team,
I need the same functionality with Up\Down Key. When I press 'Right\Enter' it should expend the selected row.
Like in following scenario I am able to Hide\Show the row details through mouse click.

void RadGridView1_RowLoaded(object sender, RowLoadedEventArgs e)
        {
            
GridViewRow row = e.Row as GridViewRow;

            row.DetailsVisibility = Visibility.Visible;
        }

But i want the handle the same with keyboard….something like this.Which is not working
 
private void RadGridView1_KeyUp(object sender, KeyEventArgs e)
        {


            
if (e.Key == Key.Enter || e.Key == Key.Right)
            {                
                
//(sender 
as GridViewDataControl).RowDetailsVisibilityMode =GridViewRowDetailsVisibilityMode

.VisibleWhenSelected;
            } 

OR
               
                 //Row in not avaialble



                 //
GridViewRow row = e.Row as GridViewRow;

                 //row.DetailsVisibility = Visibility.Visible;


        }

Thanks in advance for response.
Regards
------------------
Manmohan


Tags
GridView
Asked by
armarocha
Top achievements
Rank 2
Answers by
Vlad
Telerik team
armarocha
Top achievements
Rank 2
Stefan Dobrev
Telerik team
Lawrence
Top achievements
Rank 1
UB K
Top achievements
Rank 1
manmohan
Top achievements
Rank 1
Share this question
or