RadGrid - show gridlines even if cell is empty.

14 posts, 1 answers
  1. Priya B
    Priya B avatar
    21 posts
    Member since:
    Apr 2010

    Posted 18 Jun 2010 Link to this post

    Hi

    How do I show gridlines even if cell is empty. I want to make this fix in all places. Is there any general code for this issue?

    I have the radgrid structure like below

    <

     

    netcweb:NCRadGrid runat="server" ID="ActivityGrid"

     

     

    OnNeedDataSource="ActivityGrid_NeedDataSource"

     

     

    OnItemCreated="ActivityGrid_OnItemCreated"

     

     

    PageSize="10" AllowPaging="true" SkinID="ActivityList"

     

     

    OnPageSizeChanged="ActivityGrid_PageSizeChanged" OnPreRender="ActivityGrid_PreRender">

     

     

    <PagerStyle AlwaysVisible="true" />

     

     

    <ClientSettings AllowGroupExpandCollapse="true" />

     

     

    <GroupingSettings />

     

     

    <MasterTableView AutoGenerateColumns="false" GroupLoadMode="client">

     

     

    <Columns>

     

     

    <telerik:GridTemplateColumn UniqueName="1" HeaderText="My courses student page">

     

     

    <ItemTemplate>

     

     

    <netcweb:PlaceHolderControl runat="server" ID="column1PlaceHolder">

     

     

    </netcweb:PlaceHolderControl>

     

     

    </ItemTemplate>

     

     

    </telerik:GridTemplateColumn>

     

     

    <telerik:GridTemplateColumn UniqueName="2" HeaderText="StudentCourseListStatusHeader">

     

     

    <ItemTemplate>

     

     

    <netcweb:PlaceHolderControl runat="server" ID="column2PlaceHolder">

     

     

    </netcweb:PlaceHolderControl>

     

     

    </ItemTemplate>

     

     

    </telerik:GridTemplateColumn>

     

     

    <telerik:GridTemplateColumn UniqueName="3" HeaderText="StudentCourseListDateHeader">

     

     

    <ItemTemplate>

     

     

    <netcweb:PlaceHolderControl runat="server" ID="column3PlaceHolder">

     

     

    </netcweb:PlaceHolderControl>

     

     

    </ItemTemplate>

     

     

    </telerik:GridTemplateColumn>

     

     

    <telerik:GridTemplateColumn UniqueName="4" HeaderText="">

     

     

    <HeaderTemplate>

     

     

    <netcweb:ImageCheckBoxControl runat="server" ID="DetailedListCheckBox"

     

     

    OnCheckedChanged="DetailedListCheckBox_OnCheckedChanged" AutoPostBack="true"

     

     

    SkinID="DetailedView" />

     

     

    </HeaderTemplate>

     

     

    <ItemTemplate>

     

     

    <netcweb:PlaceHolderControl runat="server" ID="column4PlaceHolder">

     

     

    </netcweb:PlaceHolderControl>

     

     

    </ItemTemplate>

     

     

    </telerik:GridTemplateColumn>

     

     

    </Columns>

     

     

    </MasterTableView>

     

     

    </netcweb:NCRadGrid>

    I tried the below code. All the values reside that grid was returns empty.

     

     

    protected void ActivityGrid_PreRender(object sender, EventArgs e)

     

    {

     

    foreach (GridDataItem dataItem in ActivityGrid.MasterTableView.DetailTables[0].Items)

     

    {

     

    foreach (GridColumn col in ActivityGrid.MasterTableView.DetailTables[0].Columns)

     

    {

     

    if (dataItem[col.UniqueName].Text == string.Empty)

     

    dataItem[col.UniqueName].Text =

    "&nbsp;";

     

    }

    }

     

    }

     


     

     

  2. Dimo
    Admin
    Dimo avatar
    8333 posts

    Posted 18 Jun 2010 Link to this post

    Hi Priya,

    Please add "&nbsp;" at the end of the item templates. This will make the cells non-empty in all cases.

    http://www.telerik.com/community/forums/aspnet-ajax/grid/border-not-displayed-if-cell-is-empty-in-internet-explorer.aspx

    Greetings,
    Dimo
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Priya B
    Priya B avatar
    21 posts
    Member since:
    Apr 2010

    Posted 18 Jun 2010 Link to this post

    Hi Dimo,

    Thanks. Its working. But i wanted to make this for all radgrid in my projects. I have plenty of radgrids in my projects. Each radgrid I couldn'd add the "&nbsp;" manually. Is it possible to write the function in one place?



  5. Dimo
    Admin
    Dimo avatar
    8333 posts

    Posted 18 Jun 2010 Link to this post

    Hi Priya,

    You can inherit the RadGrid control and always execute an ItemDataBound or PreRender handler to add the &nbsp; string where needed. The handler can be attached in the constructor of the custom class inheriting from RadGrid.

    Kind regards,
    Dimo
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  6. Priya B
    Priya B avatar
    21 posts
    Member since:
    Apr 2010

    Posted 18 Jun 2010 Link to this post

    Could you please provide some sample?
  7. Priya B
    Priya B avatar
    21 posts
    Member since:
    Apr 2010

    Posted 21 Jun 2010 Link to this post

    I have inherited the RadGrid control and it executes both ItemDatabound/PreRender handler.
    If I add the string, all the cell value left empty. I tried the below code

    protected override void OnPreRender(EventArgs e)
     {
     ControlHelper.RegisterScriptFile("~/App/script/NCRadGrid.js");
             
           
                foreach (GridItem item in MasterTableView.Items)
                {
                 
                    foreach (TableCell cell in item.Cells)
                    {
                        cell.Text += "&nbsp;";
                    }
                }

  8. Dimo
    Admin
    Dimo avatar
    8333 posts

    Posted 21 Jun 2010 Link to this post

    Hi Priya,

    For template cells you need to add the &nbsp; string as a literal control. Setting the Text property to a table cell clears its controls collection and vice versa - adding a control to a table cell clears its Text value.

    All the best,
    Dimo
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  9. Priya B
    Priya B avatar
    21 posts
    Member since:
    Apr 2010

    Posted 21 Jun 2010 Link to this post

    Hi Dimo,

    Is there any common place to set this? As per your reply I inherited the radcontrol.

    Is it possible to add a "&nbsp;" string in common place. Because I couldn't add the "&nbsp;" string  manually for all the column in the Grid.  I have more than 50 grids in my project. Also I like to make this functionality in one place.

    I am looking forward to hear from you.
  10. Answer
    Dimo
    Admin
    Dimo avatar
    8333 posts

    Posted 21 Jun 2010 Link to this post

    Hello Priya,

    Please review carefully the attached demo.

    Dimo
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  11. Priya B
    Priya B avatar
    21 posts
    Member since:
    Apr 2010

    Posted 21 Jun 2010 Link to this post

    Hi Dimo,

    I reviewed your attached demo. I think that is not my need. I want to make this functionality in common place, not for one grid.

    I need this for all grids. After binding the grid, I should check the cell value, If it is empty I need to append the string "&nbsp;". 
    The value returns empty for me as I am using ItemTemplate. If it is a bound column, it returns a value. 

    I just want to know, how to get the cell value after binding the grid on prerender event / some other event. 

    In few grids I have placeholder and in few grids having label or literal controls. Hence I need to get the value after binding the grid. My assumptions is the grid would be in table format after binding the grid. 

    Could you please help me out from this issue?

    Please feel free to ask me, if you need more description.

     

     

  12. Dimo
    Admin
    Dimo avatar
    8333 posts

    Posted 21 Jun 2010 Link to this post

    Priya,

    The demonstrated functionality is not for one grid - it will work for all controls, which use the MyGrid class inheriting from Telerik.Web.UI.RadGrid. I believe I have provided all the information that you need.

    Dimo
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  13. Priya B
    Priya B avatar
    21 posts
    Member since:
    Apr 2010

    Posted 22 Jun 2010 Link to this post

    Hi Dimo,

    Yes, you are right. Sorry I dint notice the MyGrid.cs.

    Thanks a lot. Code is working.
  14. Luke
    Luke avatar
    10 posts
    Member since:
    Nov 2012

    Posted 20 Nov 2012 Link to this post

    You could also solve this problem with some jQuery:

      <script type="text/javascript">
         $(document).ready(function () {
            $(".RadGrid .rgRow TD:empty").append(' ');
         });
      </script>
  15. Luke
    Luke avatar
    10 posts
    Member since:
    Nov 2012

    Posted 20 Nov 2012 Link to this post

     
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017