What's New in 8.2.5
If you have not downloaded the latest version of the AgDataGrid you must! This release (8.2.5) includes some significant changes.
The grid is much much faster now. W00t!. (I know some of you have been waiting for this.) This was not an easy task. The problem is that any change to the VisualTree is an expensive operation. The less you touch it, the faster things get. With that in mind, the internal StackPanel used by the grid to present the actual data rows, and the internal RowsController have been completely rewritten. Now in 8.2.5, instead of rebuilding the tree as the grid is being scrolled, existing elements are reused and updated with values according to the data source.
Additionally, a new property was added: DelayScrolling. DelayScrolling helps a lot if you have a lot of records per data page. So as you scroll via the scroll bar, the data will be scrolled via a ticker, thus removing the "scroll delay" effect.
While we are on the topic of what's new, I should mention that after you upgrade, you will need to change your namespace references as some of them have been renamed.
- DevExpress.Windows.Data -> DevExpress.AgDataGrid.Data
- DevExpress.Windows.Data.Helpers -> DevExpress.AgDataGrid.Data.Helpers
- DevExpress.Windows.Controls.Internal -> DevExpress.AgDataGrid.Internal
- DevExpress.Windows.Controls -> DevExpress.AgDataGrid
- DevExpress.Windows.Controls.Tests -> DevExpress.AgDataGrid.Tests
- DevExpress.Windows.Controls.UIAutomation -> DevExpress.AgDataGrid.UIAutomation
You can download the latest version by visiting your Client Center area https://www.devexpress.com/ClientCenter/, or if you have not registered for the Free Silverlight Controls yet you can do so at http://devexpress.com/Products/NET/Controls/Silverlight/Register/.
Now that I got you all excited, I want to share some of the AgDataGrid tips and techniques. Namely, I want to cover the master-details scenarios. What's a RIA without the master-detail data right? :)
Master-Detail data with 2 Grids
This one is easy. Imagine 2 grids side by side one displaying customer records and the other one is showing "orders". The orders change as you scroll through the customers.
Download master records: (Note: I am using AgXPO to fetch the data from the server)
XPQuery<Customer> source = new XPQuery<Customer>(unitOfWork);
var query =
from t in source
select t;
customersGrid.DataSource = query.ToList<Customer>();
then in the FocusedRowChanged event of the customers data grid:
this.customersGrid.FocusedRowChanged +=
new FocusedRowChangedEventHandler(Customers_FocusedRowChanged);
simply:
XPQuery<Order> source = new XPQuery<Order>(unitOfWork);
var query =
from t in source
where t.CustomerID == customerId
orderby t.OrderDate descending
select t;
ordersDataGrid.DataSource = query.ToList<Order>();
Master-Detail data with 1 Grid
This one is easy as well. We can use the preview row feature of the AgDataGrid to display the detail records, and fetch the data for it in the PreviewStatus event. So if the grid is bound to the list of
public class Customer : PersistentBase {
public Customer(Session session)
: base(session) {
}
IList<Order> _orders;
[NonPersistent]
public IList<Order> Orders {
get { return _orders; }
set { _orders = value; }
}
}
Then in the PreviewStatus event, we'll fetch all orders into the Orders property and in the data template for the PreviewRow we'll make sure that we bind to this list.
<local:AgDataGrid.PreviewTemplate>
<DataTemplate>
<local:AgDataGrid DataSource="{Binding Orders}">
</DataTemplate>
</local:AgDataGrid.PreviewTemplate>
I have used both of these techniques in a little Northwind explorer app.
You can download the full source for it here
Cheers
Azret