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

Hierachical dataset child formatting

2 Answers 130 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Ali Mohamad
Top achievements
Rank 1
Ali Mohamad asked on 09 Jul 2010, 08:06 PM
Hi,

I have a hierarchical dataset being bound to the gridview and the binding works well.  The challenge I am running into is how to format the child gridview (child template).  I am formatting the parent row format (hiding columns, setting their widths, etc...) via the grid's DataBindingComplete event handler, but how do I format the children rows format?  As an example, I need to hide the first two columns in the child dataset.

Thanks
Ali M.


MORE INFO:  I am getting two datasets and binding the grid to them as shown in the code below.  I then depend on the DataBindingComplete event handler to control the visibility and size of the columns which works for the master dataset but don't know how to implement that for the child dataset.  I would change the formatting logic if this is the wrong way to do it.
Thanks

_adapter = New SqlDataAdapter()
_adapter.SelectCommand = _cmdSelect
_adapter.Fill(Me.dsSync, "Transactions")        ', "MBDeviceAuthorization")
_adapter.SelectCommand = _cmdSelect2
_adapter.Fill(Me.dsSync, "Details")
 
grdTransactionDetails.Tag = "checkouts"
grdTransactionDetails.DataSource = Me.dsSync.Tables("Transactions") ' Me.BindingSource1
Dim template As GridViewTemplate = New GridViewTemplate
template.DataSource = Me.dsSync.Tables("Details")
template.AllowAddNewRow = False
template.AllowEditRow = False
template.AllowDeleteRow = False
template.EnableGrouping = False
grdTransactionDetails.MasterGridViewTemplate.ChildGridViewTemplates.Add(template)
Dim relation As GridViewRelation = New GridViewRelation(grdTransactionDetails.MasterGridViewTemplate)
relation.ChildTemplate = template
relation.RelationName = "CheckoutItems"
relation.ParentColumnNames.Add("rowid")
relation.ChildColumnNames.Add("rowid")
grdTransactionDetails.Relations.Add(relation)

2 Answers, 1 is accepted

Sort by
0
Ali Mohamad
Top achievements
Rank 1
answered on 12 Jul 2010, 11:22 PM
No one can help?  If just a short reply to direct me...
Thanks
AM
0
Martin Vasilev
Telerik team
answered on 14 Jul 2010, 04:55 PM
Hello Ali Mohamad,

Thank you for writing.

You simply should access child template to format its columns. Form example:
 
Me.radGridView1.MasterGridViewTemplate.ChildGridViewTemplates(0).Columns(0).IsVisible = False
Me.radGridView1.MasterGridViewTemplate.ChildGridViewTemplates(0).Columns(1).Width = 100
Me.radGridView1.MasterGridViewTemplate.ChildGridViewTemplates(0).Columns(1).HeaderText = "Child Column1"

There is not anything wrong to use DataBindingComplete event for this scenario. Let me know if you have any additional questions.

Greetings,
Martin Vasilev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
GridView
Asked by
Ali Mohamad
Top achievements
Rank 1
Answers by
Ali Mohamad
Top achievements
Rank 1
Martin Vasilev
Telerik team
Share this question
or