RadGrid - Add empty rows

4 posts, 0 answers
  1. Shimon
    Shimon avatar
    2 posts
    Member since:
    Jun 2009

    Posted 14 Sep 2009 Link to this post

    Hello,

    I would like to create feeling that grid has always at least 10 rows visible, even if the datasource contains only 3 data rows.
    For that i need to able to add few fictional empty rows just to create filling effect.

    Please advise how it is possible.

    Thanks,
    Shimon
  2. Schlurk
    Schlurk avatar
    812 posts
    Member since:
    May 2009

    Posted 14 Sep 2009 Link to this post

    If you are using a DataTable object as your datasource (for example getting something from a SQL database and setting it to a DataTable object) you could count the rows, and then add more blank rows manually before you set the datasource of the grid. So for example:
    //get the data from the datasource and set it equal to a DataTable object (myTable for example) 
     
    protected void RadGrid1_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e) 
       if(myTable.Rows.Count < 10) 
       { 
           for(int i = myTable.Rows.Count; i <= 10; i++) 
           { 
              DataRow myRow = myTable.NewRow(); 
              myTable.Rows.Add(myRow); 
           } 
       } 
       RadGrid1.Datasource = myTable; 

    Just a rough idea, but I believe this should be able to work.




  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. archimede
    archimede avatar
    103 posts
    Member since:
    Jul 2006

    Posted 09 Nov 2009 Link to this post

    Hello, I've got the same problem of Shimon, but I use a LinqDataSource. If it's possible I don't want to modify my dataSource. Can someone suggest me an idea?

    best regard 
  5. Carl
    Admin
    Carl avatar
    11 posts

    Posted 12 Nov 2009 Link to this post

    Hello archimede,

    If you have your LINQ query return as a DataTable you can apply the same logic to your implementation as well. Since all of the updates are taken care of on the DataTable you will not have to commit to your actual database until you have reached the 10+ entries that you are looking for.

    Regards,
    Carl
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Back to Top