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

Hiding GridTableView row on server-side

3 Answers 116 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Mike
Top achievements
Rank 2
Mike asked on 09 Apr 2010, 03:32 PM

Hello there, I'm trying to conditionally hide a row on the server side.  My code looks like this:

protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)  
{  
    if (e.Item.ItemType == GridItemType.Item || e.Item.ItemType == GridItemType.AlternatingItem)  
    {  
        if (e.Item.OwnerTableView.Name == "Customer")  
        {  
 
        }  
 
        if (e.Item.OwnerTableView.Name == "CustomerDetail")  
        {  
            CustomerDetail detail = (CustomerDetail)e.Item.DataItem;  
            if (detail.IsCancelled)  
            {  
                // Hide the row, e.Item.Visible = false  doesn't seem to work
            }  
        }  
    }  

The good news is the code gets hit during debugging, and at that point, I'd like to hide the row.  The row does reside inside of a DetailTable/GridTableView.  Do I need to do this inside of another server side event?  Or should I filter my results when the detailtable gets databound?

I've searched these forums for quite a while but no luck . Any help is greatly appreciated.

-- Mike

3 Answers, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 2
answered on 12 Apr 2010, 07:57 AM
Hello Mike,

Try hiding the row that reside in Detailtable by setting the Display property to false.

if (e.Item.OwnerTableView.Name == "CustomerDetail"
    e.Item.Display = false

Hope this helps,
Shinu



0
kakss
Top achievements
Rank 1
answered on 17 Apr 2010, 09:24 AM
Hi,

There is a bug in the RadGrid where if you hide the row on server side (using e.Item.Display = false or e.Item.Visible = false) and using Grouping functionality of the grid then expand collapse do not work. What's happening is when doing group expand collapse it will NOT hide all the rows. See attached screenshot about the bug.


        protected void radGrid_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e) 
        { 
            switch (e.Item.ItemType) 
            { 
               case Telerik.Web.UI.GridItemType.GroupFooter:  
                    Telerik.Web.UI.GridSplitGroup splitGroup = ((System.Data.DataRowView)e.Item.DataItem)["SplitGroup"as Telerik.Web.UI.GridSplitGroup;  
  
                    if (e.Item.GroupIndex.Contains("_"))  
                    {  
                        e.Item.Display = false;  
                        e.Item.Visible = false;  
                    }  
  
                    break;  
             } 
         } 
 


0
Mike
Top achievements
Rank 2
answered on 19 Apr 2010, 02:29 PM
Thanks Shinu, it's always the simplest thing!
Tags
Grid
Asked by
Mike
Top achievements
Rank 2
Answers by
Shinu
Top achievements
Rank 2
kakss
Top achievements
Rank 1
Mike
Top achievements
Rank 2
Share this question
or