Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
733
Can't get webgrid to display hierarchical data
posted

Basically I dropped a webgrid on the page and added this code:

 

comdata.Transaction.LoadTransactions()

comdata.TransactionDetail.LoadTransactionDetails()

gridTest.DisplayLayout.ViewType = ViewType.Hierarchical

gridTest.DataSource = comdata

gridTest.DataMember =

"Transaction"

gridTest.DataBind()

The comdata dataset has a relationship defined between Transaction and TransactionDetail.  When I debug the code, the grid shows two bands with the child band having the name of the relationship (FK_Transaction_TransactionDetail).  However the grid only displays the top band (transaction) with no expansion indicators.  A call to gridTest.ExpandAll() does nothing either.  This is webgrid v 7.3.  Thanks in advance,

Bob

  • 733
    posted

    I think I figured out what was going on.  I have a strongly typed dataset with three datatables and two relations between them.  The webgrid sees the correct relationship between the two tables I wanted to display data from, but it does not allow the user to expand the rows from the parent table (no expansion indicator and expandall does nothing).  By adding a call to dataset.Relations.Clear() and then manually adding the relation back in code, the webgrid behaves properly.  Surely this is not by design.  I did notice that if the dataset has only one relation at design time, then the grid behaves properly as well.