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

Batch editing in Grid

3 Answers 46 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Mohamed
Top achievements
Rank 1
Mohamed asked on 04 May 2016, 12:20 PM

Hi there! 
i have RadGrid that i want it to be edited by user in run time which allows him to delete ,insert,and update then i have to perform this changes on the entity database so how can i do this 
how can i insert new row and get the data that inserted in each field on it
how can i get the updates

i tried this code but it returns the old data not the new one which i add by editting

 foreach (GridDataItem editedItem in RadGrid1.Items)
                {
                    Hashtable newValues = new Hashtable();
                    //The GridTableView will fill the values from all editable columns in the hash
                   int i=int.Parse( editedItem.GetDataKeyValue("id").ToString());
                   editedItem.ExtractValues(newValues);
                   akaratCBContext conn = new akaratCBContext();
                   Product p = conn.Products.Where(prd => prd.id == i).FirstOrDefault();
                  p.ProductName= newValues["ProductName"].ToString();
                  p.Description= newValues["Description"].ToString();}

3 Answers, 1 is accepted

Sort by
0
Stefan Nenchev
Telerik team
answered on 09 May 2016, 07:43 AM
Hi Mohamed,

Please review the following articles from our documentation page for more information on how to insert new row in RadGridView:

- Adding New Entries
- Adding Rows

As for getting the newly added item, you can use the RowEditEnded event and get the new data through .NewData argument. I have added a sample project for your reference. 


Regards,
Stefan Nenchev
Telerik
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
0
gaurav
Top achievements
Rank 1
answered on 14 Aug 2019, 03:17 AM

What is the best way to detect if my RadGrid in batch edit mode has had any of its cells modified and has pending unsaved changes?  I know there are some "batchEdit" commands for AJAX but I am not sure how to detect any changes to the radgrid in WPF. Can you please help me with this?

 

0
Dilyan Traykov
Telerik team
answered on 16 Aug 2019, 07:56 AM
Hello gaurav,

You can handle the various events of the RadGridView to keep track of any changes made to the items. More specifically, the CellEditEnded and RowEditEnded (which are also fired when a new item is added) and the Deleted event. You can bind these events to commands from your viewmodel by using the EventToCommandBehavior class.

If you're using EntityFramework to map your database, you can also track the changes through its DbContext as explained in this thread.

The exact implementation, however, really depends on your specific setup and requirements. If you would provide a small sample project to demonstrate your scenario, I'd be more than happy to further guide you in achieving your goal.

Please note, however, that our forum system only allows image files to be attached so you will need to upload the project to a storage provider of your choice and provide a download link.

Regards,
Dilyan Traykov
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
GridView
Asked by
Mohamed
Top achievements
Rank 1
Answers by
Stefan Nenchev
Telerik team
gaurav
Top achievements
Rank 1
Dilyan Traykov
Telerik team
Share this question
or