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

Hide NestedViewTemplate and the caret symbol

3 Answers 82 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Deepa
Top achievements
Rank 1
Deepa asked on 12 Jun 2013, 02:30 AM
Based on a search condition I need to hide the nestedview template and not show the caret symbol to the left of each grid row.

I have tried the following code on prerender, itemcreated, item databound events of the grid.It does not show the nested view but still displays the caret symbol which I don't need.

Is there a way to hide the template including the caret symbol?

Prerender:

foreach (GridDataItem item in Grd.Items)

{

if (chk != "1")

{

GridNestedViewItem nesteditem = (GridNestedViewItem)Grd.MasterTableView.GetItems(GridItemType.NestedView)[0];

nesteditem.Visible = false;

nesteditem.Enabled = false;

nesteditem.Display = false;

}}

OnItemcreated

protected void OnGrd_ItemCreated(object sender, GridItemEventArgs e)

 {

if (e.Item is GridNestedViewItem)

GridNestedViewItem nestedItem = (GridNestedViewItem)e.Item; 

var chk = "1";
if (chk != "1")

{

nestedItem.Visible = false;

}}}

OnItemDataBound:

if ((e.Item is GridNestedViewItem))

 {var p= e.Item.FindControl("GrdNest") as RadGrid;

 {chk="1"; 

if (chk == "1")

{nestedItem.Visible = true;

 p.Visible = true;

 p.DataSource = results;

 p.DataBind();

}

else

{

nestedItem.Visible = false;

nestedItem.Display = false;

 p.Visible = false;

}}}

 

3 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 1
answered on 12 Jun 2013, 10:08 AM
Hi,

Inorder to hide the expand-collapse in a RadGrid for nested view template,please check the following documentation.
Hiding the expand/collapse images

Thanks
Princy
0
Deepa
Top achievements
Rank 1
answered on 27 Jun 2013, 04:14 PM
Is it possible to disable nested view for few rows in the grid but not all rows? In that case even the caret symbol becomes visible for those few rows and not for the rest which do not have the nested view enabled
0
Maria Ilieva
Telerik team
answered on 02 Jul 2013, 08:50 AM
Hello Deepa,

Try the code below:
protected void RadGrid1_PreRender(object sender, EventArgs e)
{
    HideExpandColumnRecursive(RadGrid1.MasterTableView);
}
public void HideExpandColumnRecursive(GridTableView tableView)
{
    GridItem[] nestedViewItems = tableView.GetItems(GridItemType.NestedView);
    foreach (GridNestedViewItem nestedViewItem in nestedViewItems)
    {
      foreach (GridTableView nestedView in nestedViewItem.NestedTableViews)
      {
        if (nestedView.Items.Count == 0) //some condition
        {
          TableCell cell = nestedView.ParentItem["ExpandColumn"];
          cell.Controls[0].Visible = false;
          cell.Text = " ";
          nestedViewItem.Visible = false;
        }
       if (nestedView.HasDetailTables)
       {
        HideExpandColumnRecursive(nestedView);
        }
      }
   }
}


Regards,
Maria Ilieva
Telerik
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 the blog feed now.
Tags
Grid
Asked by
Deepa
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 1
Deepa
Top achievements
Rank 1
Maria Ilieva
Telerik team
Share this question
or