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

Hide Column in child hierarchy if no data

8 Answers 480 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jake
Top achievements
Rank 1
Jake asked on 17 Dec 2012, 02:34 PM
I was wondering how to go about hiding several column's in a child of a Hierarchical RadGrid if there is no data found for those columns. It would be quite nice to be able to do the same on the parent as well.

I've had a good search on the forums but can't find a good example to follow..

can anyone suggest a way to do this..

many thanks

8 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 18 Dec 2012, 04:21 AM
Hi,

Try the following code to achieve your scenario.
C#:
protected void RadGrid2_ItemDataBound(object sender, GridItemEventArgs e)
{
  if (e.Item is GridDataItem && e.Item.OwnerTableView.Name == "DetailTable1")
  {
     GridDataItem item = (GridDataItem)e.Item;
     if (item["Uniquename"].Text == " ")
     {
     GridTableView detailTable = (GridTableView)e.Item.OwnerTableView;
     detailTable.GetColumn("Uniquename").Display = false;
     }
   }
}

Thanks,
Shinu.
0
Jake
Top achievements
Rank 1
answered on 18 Dec 2012, 03:36 PM
Thanks Shinu..

This works if you expand one row only from the parent ..... But if you then expand another row the columns are hidden on the new expanded hierarchy form...  but they become visible again on the original hierarchy expansion..  ie.. Only on the current expansion are the columns hidden....  is there a solution to hide these columns all the time if there is no data?
0
Eyup
Telerik team
answered on 20 Dec 2012, 09:27 AM
Hello Jake,

You can use the following approach to achieve the requested appearance:
http://www.telerik.com/help/aspnet-ajax/grid-hide-expand-collapse-images-when-no-records.html
nestedView.GetColumnSafe("ShipCountry").Visible = false;

I hope this will prove helpful.

Kind regards,
Eyup
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Jake
Top achievements
Rank 1
answered on 21 Dec 2012, 08:55 AM
thanks Eyup, sounds like what I need but a little lost in how to implement it..
0
Eyup
Telerik team
answered on 24 Dec 2012, 07:30 AM
Hi Jake,

You can find a working sample application in the following thread:
http://www.telerik.com/community/forums/aspnet-ajax/grid/hide-a-column-in-details-view-programatically.aspx

I hope this helps.

Regards,
Eyup
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Jake
Top achievements
Rank 1
answered on 24 Dec 2012, 03:08 PM
NIce one!..

Many thanks Eyup.. I had to change the condition from != to == for my scenario but the function works perfectly..

 
0
Jake
Top achievements
Rank 1
answered on 24 Dec 2012, 04:37 PM
mmm.. thought this had fixed it..

actually further testing the grid exhibits the same behavious as shinu's code. if you expand one row the columns are correctly hidden but if another row is expanded in the original row the hidden columns become visible.
0
Eyup
Telerik team
answered on 25 Dec 2012, 12:46 PM
Hello Jake,

I am afraid we are not able to replicate the issue. Could you please provide the exact steps to reproduce the problem using the mentioned application?

Regards,
Eyup
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Grid
Asked by
Jake
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Jake
Top achievements
Rank 1
Eyup
Telerik team
Share this question
or