Hi,
I would like to know:
a) How to insert a new row in the RadGridView by clicking on a button rather than pressing the insert key.
b) How can i also insert multiple rows using the button? Currently when pressing the insert key twice does not insert 2 new rows.
Regards,
Mark.
I would like to know:
a) How to insert a new row in the RadGridView by clicking on a button rather than pressing the insert key.
b) How can i also insert multiple rows using the button? Currently when pressing the insert key twice does not insert 2 new rows.
Regards,
Mark.
3 Answers, 1 is accepted
0
Hello MarkBr,
The Insert key is intended to toggle between visible and hidden state of the new row. So pressing it multiple times will just toggle visibility multiple times.
The workaround is to add multiple empty records to the ItemsSource of the grid on pressing a button. Later the user may focus and edit the empty cells.
I am preparing a sample project for you to demonstrate how this may be done. I'll send it to you later today.
Regards,
Pavel Pavlov
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
The Insert key is intended to toggle between visible and hidden state of the new row. So pressing it multiple times will just toggle visibility multiple times.
The workaround is to add multiple empty records to the ItemsSource of the grid on pressing a button. Later the user may focus and edit the empty cells.
I am preparing a sample project for you to demonstrate how this may be done. I'll send it to you later today.
Regards,
Pavel Pavlov
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Gavin Bryan
Top achievements
Rank 1
answered on 14 Jan 2009, 01:33 AM
Hi Pavel
I would also be interested in this project to see how this is done. Is it also possible to have a copy of the sample project ?
Thanks
Gavin
I would also be interested in this project to see how this is done. Is it also possible to have a copy of the sample project ?
Thanks
Gavin
0
Hi Gavin Bryan,
I am attaching Pavel's project. It binds to an ObservableCollection of Customer objects and upon clicking the Add Customers button inserts five empty objects. RadGridView picks those up and displays them in empty rows:
The code also keeps track of newly-inserted customers by storing them in the pendingCustomers collection. Those customers are sent to the server whenever the user clicks the Save button:
Sincerely yours,
Hristo Deshev
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
I am attaching Pavel's project. It binds to an ObservableCollection of Customer objects and upon clicking the Add Customers button inserts five empty objects. RadGridView picks those up and displays them in empty rows:
private void Add5Rows() |
{ |
ObservableCollection<Customer> data = (ObservableCollection<Customer>) this.RadGridView1.ItemsSource; |
for (int i = 0; i < 4; i++) |
{ |
Customer blankCustomer = new Customer() { CustomerID = -1 }; |
data.Add(blankCustomer); |
pendingCustomers.Add(blankCustomer); |
} |
} |
private void AddCustomers_Click(object sender, RoutedEventArgs e) |
{ |
Add5Rows(); |
} |
The code also keeps track of newly-inserted customers by storing them in the pendingCustomers collection. Those customers are sent to the server whenever the user clicks the Save button:
private void SaveNewCustomers_Click(object sender, RoutedEventArgs e) |
{ |
SavePendingCustomers(); |
} |
private void SavePendingCustomers() |
{ |
foreach (var Customer in this.pendingCustomers) |
{ |
client.AddCustomerAsync(Customer); |
} |
this.pendingCustomers.Clear(); |
} |
Sincerely yours,
Hristo Deshev
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.