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

Close row edit without sync'ing datasource

5 Answers 170 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Dawn
Top achievements
Rank 1
Dawn asked on 03 Dec 2013, 03:18 AM
I have a grid with edit mode set to 'inline'.
It has a remote dataSource with only the transport 'read' options set.

I am looking for a way to close a row edit (similar to closeCell, but for a whole row) in the grid , without the grid attempting to update the dataSource.

THE PROBLEM:   
At the moment, if I call saveRow, a dataSource sync is attempted, but fails and the grid remains in edit mode.  If I call cancelRow, the updates are lost from
the grid.

The sync fails as no transport 'update' option is specified in the dataSource. I do not want to specify the transport update, create and destroy options, as  I
want to perform my own updates, rather than have the dataSource do this. I want to maintain the updates in the grid (with red triangles to say which cells are dirty), and then manually post these to my server at the appropriate time, rather than have the dataSource do this immediately.

So when the user clicks the row's "edit" button the whole row must go into edit mode, the user captures the data and clicks the "save" button. 
I want to
1. visually take the row out of edit mode,
2. still show the red triangles for the data that is dirty,
3. raise an event that the grid row has been committed.
4. A separate class can subscribe to this event and be responsible for saving the dirty grid data.
5. We will use Signal R to notify database changes to the client, which will refresh these changed rows in the grid and remove the red triangles.

I am having problems with points 1 and 2.

Any help would be appreciated. Thanks.

5 Answers, 1 is accepted

Sort by
0
Vladimir Iliev
Telerik team
answered on 04 Dec 2013, 12:23 PM
Hi Dawn,


Please note that you can pass a function to the "update" action of the grid dataSource in which to notify your custom function that the data is updated and return empty array to signify success. Please check the example below:

dataSource: {
    transport: {
        update: function (e) {
            //call your to function as the data is changed
 
            //return empty array to the DataSource to signify success
            e.success([]);
        },


Kind Regards,
Vladimir Iliev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Dawn
Top achievements
Rank 1
answered on 04 Dec 2013, 07:46 PM
Hello Vladimir,

Thank you for your reply. I tried that, but I still get the same result, namely, the sync is attempted and fails and the row stays in edit mode.

In the update function, I have put an alert and attached the debugger to test if the update function is called, but these are never run, meaning the update function is never called.

I have created a jsbin to demonstrate this at http://jsbin.com/UmEWiMO/2/edit.

I have attached 2 screenshots. The first shows the state after I click the edit button on the second row in the grid and change the product name from 'Chang' to 'Change' then click the Update button. As you can see the row is still in edit mode and the console shows an error has been thrown.

The second shows the network requests. The sync has attempted to send the changed data to the current url (in this case jsbin). This is not what I expected. If I supply a function to the update, I expect the sync to run my function to post the update rather than attempt to use the current url to post the update.

0
Vladimir Iliev
Telerik team
answered on 06 Dec 2013, 01:37 PM
Hi Dawn,

Please note that you can't combine actions with different types - currently the "read" action is object and the "update" action is a function which is invalid configuration. For convenience I updated the example to use only functions for both the "read" and "update" actions in order to work as expected:

Regards,
Vladimir Iliev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Dawn
Top achievements
Rank 1
answered on 10 Dec 2013, 03:50 AM
Hi Vladimir,

Thank you for your response. I changed both my read and update to a function and I can now use the saveRow method without the dataSource attempting to perform the sync.

The kendo datasource api documentation does not mention that if you use a function for update, you also have to use a function for the read, and as far as I can see there is no logical reason why this should be so (If there is, please inform me) . I therefore suggest the documentation be updated to specify this, as had I known, I could have saved many hours spent trying to debug what was going wrong.

Thanks again for your help.
Dawn
0
Vladimir Iliev
Telerik team
answered on 10 Dec 2013, 12:49 PM
Hi Dawn,

Basically depending on the type of the "read" configuration option different types of KendoUI transport is initialized (Local or Remote) - that why the "read" option should be the same type as the other transport options (either function or object,string). Also we will consider describing more detailed that behavior in our API documentation. 

Regards,
Vladimir Iliev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Grid
Asked by
Dawn
Top achievements
Rank 1
Answers by
Vladimir Iliev
Telerik team
Dawn
Top achievements
Rank 1
Share this question
or