13 Answers, 1 is accepted
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.
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
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.
Thanks for your sample, this is exactly what I needed.
Best regards,
Armando Rocha
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
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.
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?
Best regards,
Armando Rocha
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.
The ScrollViewer not work.
Thanks anyway
Best regards,
Armando Rocha
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.
Is there a way to achieve the same thing with Visual Studio 2005 (ASP.NET C#) and Oracle 10g?
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
