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

Horizontal grid lines disappear in NULL cells

7 Answers 101 Views
Grid
This is a migrated thread and some comments may be shown as answers.
neebs
Top achievements
Rank 2
neebs asked on 20 Jul 2008, 03:05 PM
This has been a problem for quite some time, not necessarily associated with RadControls for ASP.NET Ajax, but it still occurs in this latest version. Many of the skins provided display horizontal divider lines between rows. However if a cell displays a value which is NULL, the divider line does not appear for that cell only. This is especially noticeable if the row is selected. Is this a known issue?

7 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 21 Jul 2008, 03:52 AM
Hi,

Try the following code snippet in the PreRender event.

CS:
protected void RadGrid2_PreRender(object sender, EventArgs e)  
    {  
        foreach (GridDataItem dataItem in RadGrid2.Items)  
        {  
            foreach (GridColumn col in RadGrid2.Columns)  
            {  
                if (dataItem[col.UniqueName].Text == string.Empty)  
                    dataItem[col.UniqueName].Text +=  " ";   
   
            }  
        }  
    }  


Thanks
Shinu.
0
neebs
Top achievements
Rank 2
answered on 22 Jul 2008, 07:14 AM
This fixes the null columns at the expense of wiping out all my template columns.

Steve
0
Sebastian
Telerik team
answered on 22 Jul 2008, 07:19 AM
Hi neebs,

I think that the information from this forum thread will help you address the issue you are currently facing:

http://www.telerik.com/community/forums/thread/b311D-bbcdct.aspx

Best regards,
Stephen
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
neebs
Top achievements
Rank 2
answered on 22 Jul 2008, 03:29 PM
I'm still left with blanks in all my template columns using this technique. Is there any way to set the displayed element for template columns to  ?

Steve
0
Dimo
Telerik team
answered on 22 Jul 2008, 04:03 PM
Hello Steve,

When using template columns, the easier way is to simply add   at the end of your item template and not do any checks at runtime.

Best wishes,
Dimo
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
neebs
Top achievements
Rank 2
answered on 29 Jul 2008, 06:48 PM
Hello,

I have implemented the code provided as follows:

    protected void RadGridJobs_PreRender(object sender, EventArgs e) 
    { 
        foreach (GridDataItem dataItem in RadGridJobs.Items) 
        { 
            foreach (GridColumn col in RadGridJobs.Columns) 
            { 
                if (col.ColumnType != "GridTemplateColumn") 
                { 
                    if (dataItem[col.UniqueName].Text == string.Empty) 
                    { 
                        dataItem[col.UniqueName].Text = " "
                    } 
                } 
            } 
        } 
    } 
 

and it works, however as this is a master/detail grid view, a problem occurs when this is executed on the detail expansion. It fails with an exception because col.UniqueName is the name of a master table column, but it is iterating through the detail table. This causes the following message to appear:

Cannot find a cell bound to column name 'Summary'

where 'Summary' is the name of a master table column that doesn't exist in the detail table. I have looked for a way to determine whether the detail or master row is being rendered, but have not found anything. For now, I'll trap the exception, however I will need to apply the same logic to the detail table to prevent the missing grid lines.

If you have a code snippet, I would appreciate it.

Steve


0
Princy
Top achievements
Rank 2
answered on 30 Jul 2008, 12:48 PM
Hi neebs,

Try setting the Name property for the Master table and Detail table and try the following code snippet to achieve the desired scenario.

ASPX:
 <MasterTableView  CommandItemDisplay="Bottom" Name="Master" > 
         ..........  
          <DetailTables> 
                 <telerik:GridTableView runat="server" Name="Detail"  > 
                    .............  
                 


CS:
protected void RadGrid1_PreRender(object sender, EventArgs e)  
    {  
        foreach (GridDataItem dataItem in RadGrid1.Items)  
        {  
            if (dataItem.OwnerTableView.Name == "Master")  
            {  
                foreach (GridColumn col in RadGrid1.Columns)  
                {  
                    if (col.ColumnType != "GridTemplateColumn")  
                    {  
                        if (dataItem[col.UniqueName].Text == string.Empty)  
                        {  
                            dataItem[col.UniqueName].Text = "&nbsp;";  
                        }  
                    }  
                }  
            }  
            else if (dataItem.OwnerTableView.Name == "Detail")  
            {  
                foreach (GridColumn col in RadGrid1.MasterTableView.DetailTables[0].Columns)  
                {  
                    if (col.ColumnType != "GridTemplateColumn")  
                    {  
                        if (dataItem[col.UniqueName].Text == string.Empty)  
                        {  
                            dataItem[col.UniqueName].Text = "&nbsp;";  
                        }  
                    }  
                }  
            }  
        }   
    } 


Regards
Princy.
Tags
Grid
Asked by
neebs
Top achievements
Rank 2
Answers by
Shinu
Top achievements
Rank 2
neebs
Top achievements
Rank 2
Sebastian
Telerik team
Dimo
Telerik team
Princy
Top achievements
Rank 2
Share this question
or