Print Page | Close Window

DevExpress Grid

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce 2009
Forum Discription: For .NET 3.5
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=990
Printed Date: 28-Apr-2026 at 12:20am


Topic: DevExpress Grid
Posted By: pucsoftware
Subject: DevExpress Grid
Date Posted: 06-Nov-2008 at 11:34am
I have a newly converted DevForce classic to DevForce EF application. I was using the DevExpress grid control heavily in the application, but I am having problems in the new EF version. When trying to bind a parent view with a child view in the grid the child relationships are not recognized in the child view. Usually, this link is established by using the ChildGridLevelName property of the ParentView and setting this value, as well as the Child level of the child view, to the same name. This is supposed to be the name of the property in the object that denotes the relationship.
 
For example if I have an Object named Departments with a property that is a collection of Employees, by setting the relationship properties with the name of "Employees", the grid will recognise the collection of child objects. From there the designer can retrieve all the fields. I can't seem to get this to work now. Has anyone else run into this? If so, what's the fix?
 


-------------
puctx



Replies:
Posted By: davidklitzke
Date Posted: 11-Nov-2008 at 10:02am

This advice is taken from porting a DevEx Hierarchical Grid from DevForce Classic to DevForce EF.

 
Assume that Customer is parent object and Order is the child object.  
 
             Try using a BindableList as the DataSource. The BindableList has special code that allows it to operate with advanced features of various grids.  So just move the results of your EF queries into a BindableLists.

  

                Try creating a new property on you customer object called “Orders2”.  This property should be a BindableList<Order>.  Then bind to Orders2 instead of Orders in your AddRelationView line.

 

Here is the custom property on Customer:

 

    public BindableList<Order> Orders2 {

      get {

        BindableList<Order> mOrders = new BindableList<Order>();

        mOrders.AddRange(this.Orders);

        return mOrders;

      }

    }

 

Here is the final code for the nested grid:

  

      _ordersXGBM.GridView = _customersXGBM.AddRelationView("Order", "Orders2");

      this.gridView2.LayoutChanged();

      _ordersXGBM.GridView.OptionsView.NewItemRowPosition = DevExpress.XtraGrid.Views.Grid.NewItemRowPosition.Bottom;

 

 




Print Page | Close Window