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

Bug when canceling an edit using local data

7 Answers 992 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jeff
Top achievements
Rank 1
Jeff asked on 15 Dec 2013, 09:48 PM
Overall, the kendo grid is fantastic for working with remote data but has issues when attempting to do anything more than display items from a local array. 

I have been able to work around most of the issues but there seems to be a bug in the grid code which appears when you add an item to the grid then attempt to add another item. If you cancel the addition of the second item, all items added to the grid disappear.

See this jsFiddle and follow these steps to see an example of the problem :

  1. Click the 'Add Item' button in toolbar above the grid.
  2. Enter values in each column (i.e. 'name005', '005', 'G5'.
  3. Click the 'Update' button in the far right column.
  4. Click the 'Add Item' button again.
  5. Click the 'Cancel' button in the far right column.
  6. Note that the first new row (name005) is gone! It will delete all new items, not just the last one.
I've tried numerous combinations of saveRow(), saveChanges(), sync(), etc but nothing seems to work. The items are definitely added to dataSource but it is somehow overwritten when the Cancel button is clicked. It's almost like the original array is read back in. 

While typing this, I just found a way around this issue but it's definitely not very "clean". A quick test in my production code seems to show that creating a new DataSource using the data from the existing data source seems to work in initial tests. Something like this:
1.function _onGrdItemsSaveChanges(oEvt) {
2.    var tDS = new kendo.data.DataSource(oEvt.sender.data);
3.    $('#grdItems').data('kendoGrid').setDataSource(tDS);
4.}
Could someone please look into this issue?

Thanks

7 Answers, 1 is accepted

Sort by
0
Jeff
Top achievements
Rank 1
answered on 15 Dec 2013, 10:06 PM
Here is a jsFiddle with the kludgy but usable workaround.
0
Kiril Nikolov
Telerik team
answered on 16 Dec 2013, 12:07 PM
Hi Jeff,

The problem comes from the fact that when local data is used, you do not updated the initial array when a value inside the grid is changed. In order to updated the grid correctly, you need to implement local transport functions (working with the local data), so the grid will work as expected. 

Please check this jsBin showing a possible implementation:

http://jsbin.com/OHUBAcA/1/edit

Regards,
Kiril Nikolov
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Enrique
Top achievements
Rank 1
answered on 01 Oct 2014, 04:43 AM
That made the trick for me! Great. thanks.
0
Kiril Nikolov
Telerik team
answered on 01 Oct 2014, 11:09 AM
Hello Enrique,

I am happy to hear that the example helped.

In case you have any questions, please do not hesitate to contact us.

Regards,
Kiril Nikolov
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
ASHISH
Top achievements
Rank 1
answered on 04 May 2018, 08:54 AM

Hi,

I have just go through your demo "http://jsbin.com/OHUBAcA/1/edit" but does not work if i add dropdown list in column.

Thanks for quick response.

Ashish

0
Preslav
Telerik team
answered on 08 May 2018, 07:58 AM
Hi Ashish,

Could you please elaborate on the code that is not working?

In the meantime, below you could find articles and demos on drop-downs in the Grid:

I look forward to hearing from you.


Regards,
Preslav
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Dusan
Top achievements
Rank 1
Iron
answered on 05 Aug 2022, 08:09 AM | edited on 05 Aug 2022, 08:10 AM

The problem still persist, even if CRUD operations of local data source is implemented.

DOJO example

Steps to reproduce:

- press plus to add new row

- insert some values and confirm entry

- edit newly inserted row

- cancel changes - editor stays open, an exception is present in console..

I even tried implementing DS transport as suggested  in https://docs.telerik.com/kendo-ui/knowledge-base/local-data-editing, but with no success.

BR

 

Georgi Denchev
Telerik team
commented on 09 Aug 2022, 07:15 AM

Hello, Dusan,

Looking at the provided Dojo, it seems like you're attempting to mix MVVM initialization with regular widget initialization. This could lead to potential issues.

I would recommend that you choose one of the approaches and use it.

Let me know in case the issue continues to persist after that.

Best Regards,

Georgi

Tags
Grid
Asked by
Jeff
Top achievements
Rank 1
Answers by
Jeff
Top achievements
Rank 1
Kiril Nikolov
Telerik team
Enrique
Top achievements
Rank 1
ASHISH
Top achievements
Rank 1
Preslav
Telerik team
Dusan
Top achievements
Rank 1
Iron
Share this question
or