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

Blank Row showing in Hierarchy Table

2 Answers 84 Views
Grid
This is a migrated thread and some comments may be shown as answers.
David Kucharski
Top achievements
Rank 1
David Kucharski asked on 28 Apr 2015, 02:26 AM

I have a radgrid on my page. It has a Details Table for children. For the parent rows that have no children I do now want any row(s) to show. I have used the below code and when I do, I still see a blank row underneath my parent row. What am I doing wrong?

The attached file is how my grid looks.

//If the details have no records, make it invisible  
      protected void rgCirculationDetails_ItemCreated(object sender, GridItemEventArgs e)
        {
            if (e.Item is GridNoRecordsItem && e.Item.OwnerTableView != rgCirculationDetails.MasterTableView)
                e.Item.OwnerTableView.Visible = false;
        }
  
//below code puts an empty string for a parent row that has no children
        protected void rgCirculationDetails_DetailTableDataBind(object sender, GridDetailTableDataBindEventArgs e)
        {
            try
            {
                GridDataItem parentItem = e.DetailTableView.ParentItem as GridDataItem;
  
                int parentRow = Convert.ToInt32(parentItem.GetDataKeyValue("ParentRow"));
                string geography = parentItem.GetDataKeyValue("Geography").ToString().Trim();
  
                if (e.DetailTableView.DataMember == "GeographyRows")
                {
                    if (parentRow == 1)
                    {
                        circulationServiceObj.CircDetail = circulationObj.GetCircDetailsForParentRow(circSetID, geography, dayID).CircDetail;
                        e.DetailTableView.DataSource = circulationServiceObj.CircDetail.CircDetail;
                    }
                    else
                    {
                        e.DetailTableView.DataSource = String.Empty;
                    }
                }
            }
            catch (SoapException ex)
            {
            }
        }

 

2 Answers, 1 is accepted

Sort by
0
Accepted
Kostadin
Telerik team
answered on 30 Apr 2015, 01:11 PM
Hello David,

Thank you for contacting us.

The reason for that behavior is that you are hiding the DetailTableView but you need to hide the GridNestedViewItem. A possible solution is to call parent until you get the GridNestedViewItem or use the hardcode approach.
if (e.Item is GridNoRecordsItem && e.Item.OwnerTableView != RadGrid1.MasterTableView)
{
    e.Item.OwnerTableView.Parent.Parent.Visible = false;
}

Please give it a try and let me know about the result.

Regards,
Kostadin
Telerik
 

See What's Next in App Development. Register for TelerikNEXT.

 
0
David Kucharski
Top achievements
Rank 1
answered on 05 May 2015, 01:59 PM
Thank you Kostadin. That did it.
Tags
Grid
Asked by
David Kucharski
Top achievements
Rank 1
Answers by
Kostadin
Telerik team
David Kucharski
Top achievements
Rank 1
Share this question
or