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

InLine Edit Bug???

2 Answers 133 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Randy Hompesch
Top achievements
Rank 1
Randy Hompesch asked on 18 Aug 2019, 10:40 AM

If I have things set up for inline editing and I click on the add button on the toolbar and create my new item, all is well.
The problem crops up when, immediately after saving the new item, I then click on teh edit button for that item. It then correctly opens up the line to make changes,
but you hit update you're create function gets called instead of the update function. Thus I end up with duplicates.

Thanks … Ed

 


2 Answers, 1 is accepted

Sort by
0
Randy Hompesch
Top achievements
Rank 1
answered on 19 Aug 2019, 09:15 AM

But wait!!! There's more! 

Add an item, hit update (which in theory causes it to go out of edit mode), then hit the save button on the toolbar. You end up with duplicates. Now I have removed the save button from the toolbar, since it doesn't make sense in the inline edit case. I would argue that you should not allow having a save button in the toolbar if you are inline editing. 

My 2 cents.

Thanks … Ed

 

0
Viktor Tachev
Telerik team
answered on 21 Aug 2019, 02:43 PM

Hi Randy,

 

When editing and inserting items the Kendo DataSource component uses the value of the ID field to determine if the item is new or already existing. The behavior you describe can be observed when the value of the ID field matches the default one for the type. For example zero for int property.

In order to avoid this make sure that when creating an item its ID field is populated correctly and the new item is returned back to the Grid. Also, make sure that there are no IDs that match the default value. You can control that by setting the DefaultValue in DataSource Model configuration.

.Model(model =>
{
	model.Id(p => p.ProductID);
	model.Field(p => p.ProductID).DefaultValue(-1);
})

 

Regards, Viktor Tachev
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
Grid
Asked by
Randy Hompesch
Top achievements
Rank 1
Answers by
Randy Hompesch
Top achievements
Rank 1
Viktor Tachev
Telerik team
Share this question
or