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

After Inserting Row in GridView, How Can I Update the new Selected, Editable Row in the GridView Prior to User's Edit Being Complete?

1 Answer 8 Views
GridView
This is a migrated thread and some comments may be shown as answers.
John
Top achievements
Rank 1
John asked on 04 Jul 2019, 06:40 AM

Hey guys,

I have a RESTful server I've created which stores simple objects with a few fields. I have a WPF project that has a RadGridView. It loads these objects just fine from my server. I've also managed to use both the AddingNewDataItem and RowEditEnded listeners to be able to 1) listen for a user creating a new row, 2) create an object on the server with the user's specified fields and 3) store the newly created object returned from the server (with a unique ID) in an ObservableCollection linked to the GridView.

Here's the problem. If I submit the new object to the server via the AddingNewDataItem listener, I can successfully add it to my ObservableCollection. The way the GridView UI works, however, it immediately brings up a selected row with edit enabled upon hitting insert or clicking on the "insert new row" bar. I have not figured out how to update this UI element with the data from the server. I've tried this many, many different ways, but the UI element that opens remains the same. What I have been able to successfully do is replace that row **after** using the RowEditEnded listener. This kinda works but looks odd as certain fields change after the user is done editing and there's no reason I couldn't just show the unique ID retrieved from the server, for example, **before** editing is complete. I've also tried to use AddingNewDataItem listener to listen for the insert request, create a blank object on the server with a new unique ID, and show that object data in the newly created and displayed selected, editable row in the GridView. I have not figured out a way to do this, however. I am able to successfully create a new object on my server and to add that object to my Observable Collection, but I can't seem to find a way to update the data in the newly added row in the UI before the edit is complete. I feel like I've tried so many different ways of trying to find and replace the incorrect objects in the GridView.Items and GridView.Itemsource collections, but to no avail. 

Surely there's an easy way to do this? Thanks in advance! Let me know if you need more info. I could provide code, but I think this is more of a conceptual issue I need to figure out as I've tried to do this like literally 15 different ways. They all sort of work, but don't let me update the UI when I want to do it, so I suspect I'm missing a method or event handler that is more suited to what I'm trying to do. 

1 Answer, 1 is accepted

Sort by
0
Yoan
Telerik team
answered on 08 Jul 2019, 04:18 PM
Hello John,

In order to avoid double posting, I would like to kindly ask you to keep any further communication in this forum thread or in your support ticket. For convenience, I will paste my answer here as well:

Thank you for the detailed explanation.

I am afraid that I was not able to open  your project. It does not loads the client application. However, I have prepared a sample project that you can find attached. It shows you to possible approaches. By clicking on the Add new club to source collection you will add a new object directly in the source collection of RadGridView. RadGridView's source collection is ObservableCollection, so after you add the new object, the UI will be updated.

I have demonstrated the other approach - by using the AddingNewDataItem event. As you can see, after hitting the Insert key, a new row with correctly populated fields is added in RadGridView.

Please let me know if you need further assistance with one of these approaches.


Regards,
Yoan
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
John
Top achievements
Rank 1
Answers by
Yoan
Telerik team
Share this question
or