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

Executing kendo transport functions to CRUD remote data

3 Answers 167 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jason
Top achievements
Rank 1
Jason asked on 23 Oct 2013, 09:18 AM
I am stuck for a couple of days now with the kendo grid.
When I select a row in the grid, I save it inside an Angular scope variable.
When I click edit a custom edit screen opens with the data of the selected row.
After saving the changes, I want to call the "update" function from the dataSource.transport.
But my server returns a new "EditedDate", so I also want to call the e.success() callback in my update function.

When I call the dataSource.transport.update(editedObject), I only have the object in my function, without an e.success() to update the grid row.
When I call the dataSource.remove() or the dataSource.add() and then the dataSource.sync() everything goes well.

I'm just not able to update any row, because I also need the e.success().

create: function (e) {
 //custom createfunction with callback
 vm.CourseFactory.Insert(e.data, function success(data) {
  e.success(data);
 });
},
update: function (e) {
 //custom update function with callback
 vm.CourseFactory.Update(e.data, function success(data) {
  e.success(data);
 });
},
the dataSource.add(newObject), calls the create function with an e.data and an e.success
I need the same kind of function for my update function, but I only found add() and remove()
and dataSource.transport.update() is not what I'm looking for.

Any help would be appreciated!

3 Answers, 1 is accepted

Sort by
0
Petur Subev
Telerik team
answered on 25 Oct 2013, 08:23 AM
Hello Jason,

I am not sure if I fully understand the case. 

Basically if you want to edit an existing record from the dataSource then:

1) First get it with the get method (or getByUid if it is more convenient).

2) Make changes to it with the set method of that particular model (dataItem).

3)You synchronize the changes with the sync method of the dataSource.

Then the update function of your transport should be invoked.

I hope this helps.

Kind Regards,
Petur Subev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Jason
Top achievements
Rank 1
answered on 25 Oct 2013, 10:34 AM
Hi, 

Yes thats what I meant, but the set() method is not exactly what I was looking for, because I sometimes have 20 attributes to update.
Is there an option to update the whole row at once? The set method doesn't seem to accept an object right?

like: dataItem.set(updatedObject);

thanks so far!
0
Petur Subev
Telerik team
answered on 25 Oct 2013, 11:19 AM
Hello Jason,

I am afraid that the framework does not expose such method which allows you to update all the fields of a dataItem at once.

Kind Regards,
Petur Subev
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
Jason
Top achievements
Rank 1
Answers by
Petur Subev
Telerik team
Jason
Top achievements
Rank 1
Share this question
or