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

RadGrid - Add empty rows

3 Answers 323 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Shimon
Top achievements
Rank 1
Shimon asked on 14 Sep 2009, 12:32 PM
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

3 Answers, 1 is accepted

Sort by
0
Schlurk
Top achievements
Rank 2
answered on 14 Sep 2009, 02:10 PM
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.




0
archimede
Top achievements
Rank 1
answered on 09 Nov 2009, 01:40 PM
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 
0
Carl
Telerik team
answered on 12 Nov 2009, 03:48 PM
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.
Tags
Grid
Asked by
Shimon
Top achievements
Rank 1
Answers by
Schlurk
Top achievements
Rank 2
archimede
Top achievements
Rank 1
Carl
Telerik team
Share this question
or