We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on : November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How add new row programmatically in SfDataGrid ?

Thread ID:

Created:

Updated:

Platform:

Replies:

126338 Oct 8,2016 06:34 PM UTC Oct 18,2016 07:14 PM UTC UWP 6
loading
Tags: SfDataGrid
Azem
Asked On October 8, 2016 06:34 PM UTC


Hello Syncfusion team.

for example I add new col:

Dim col As New Syncfusion.UI.Xaml.Grid.GridTextColumn
col.HeaderText = "test col"
sfGrid.Columns.Add(col)

how to add a row in this column?

Thanks!


Jai Ganesh S [Syncfusion]
Replied On October 10, 2016 10:47 AM UTC

Hi Azem, 
You can achieve your requirement for adding a new row at rime like  blow, 
private void Button_Click(object sender, RoutedEventArgs e) 
{ 
  (this.sfGrid.DataContext as UserInfoViewModel).UserDetails.Add(new UserInfo() { UserId=4001, Name="George", DateofBirth=DateTime.Now, City="Kolalambur",Salary=52000 }); 
} 
 
Also we already have a kb to add the new row programmatically, 
Kb Link: 
Regards, 
Jai Ganesh S 


Azem
Replied On October 15, 2016 04:00 PM UTC

Hi Azem, 
You can achieve your requirement for adding a new row at rime like  blow, 
private void Button_Click(object sender, RoutedEventArgs e) 
{ 
  (this.sfGrid.DataContext as UserInfoViewModel).UserDetails.Add(new UserInfo() { UserId=4001, Name="George", DateofBirth=DateTime.Now, City="Kolalambur",Salary=52000 }); 
} 
 
Also we already have a kb to add the new row programmatically, 
Kb Link: 
Regards, 
Jai Ganesh S 


Hello, Syncfusion team!

necessarily must be the source in SfDataGrid?

Thanks!

Azem
Replied On October 15, 2016 04:16 PM UTC

Hi Azem, 
You can achieve your requirement for adding a new row at rime like  blow, 
private void Button_Click(object sender, RoutedEventArgs e) 
{ 
  (this.sfGrid.DataContext as UserInfoViewModel).UserDetails.Add(new UserInfo() { UserId=4001, Name="George", DateofBirth=DateTime.Now, City="Kolalambur",Salary=52000 }); 
} 
 
Also we already have a kb to add the new row programmatically, 
Kb Link: 
Regards, 
Jai Ganesh S 


Hello, Syncfusion team!

necessarily must be the source in SfDataGrid?

Thanks!


I want to programmatically create a rows in SfDataGrid.
creating classes (collections) are not suitable for me (at the moment).



Jai Ganesh S [Syncfusion]
Replied On October 17, 2016 11:44 AM UTC

Hi Azem,  
We cannot understand your requirement clearly. But we suspect that you want to add the new row at run time without using the Collection. This requirement can be achieved in SfCellGrid by inserting the rows at runtime like below, 
 
private void Button_Click(object sender, RoutedEventArgs e) 
{ 
   //To insert rows (Param : 5 => insert row index , 2=> number of rows to be inserted) 
   this.cellGrid.Model.InsertRows(5, 2); 
} 
 
 
 
Regards, 
Jai Ganesh S 


Azem
Replied On October 18, 2016 03:49 PM UTC

Hi Azem,  
We cannot understand your requirement clearly. But we suspect that you want to add the new row at run time without using the Collection. This requirement can be achieved in SfCellGrid by inserting the rows at runtime like below, 
 
private void Button_Click(object sender, RoutedEventArgs e) 
{ 
   //To insert rows (Param : 5 => insert row index , 2=> number of rows to be inserted) 
   this.cellGrid.Model.InsertRows(5, 2); 
} 
 
 
 
Regards, 
Jai Ganesh S 


exactly what is needed!

Thanks!

Jai Ganesh S [Syncfusion]
Replied On October 18, 2016 07:14 PM UTC

Hi Azem, 
Thank you for the update. 
Please let us know if you need further assistance on this. 
Regards, 
Jai Ganesh S 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;