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

[Solved] Client Events not working with Databinding commands

1 Answer 86 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Ryan Black
Top achievements
Rank 1
Ryan Black asked on 08 Apr 2011, 06:52 PM
Hey Telerik!

I just fixed a problem where the client side javascript onSave was not working.  The reason was because I was binding the 'DateCreated' column with the grid and I had that specific property set to  [ScaffoldColumn(false)] in MVC.

My new question is:  How can I add a callback function on a commands.Edit()  Essentially, I would like to 

1.  Click Edit or Delete
2.  Have the MVC code update the record in the database and return that everything was good, etc.
3.  Callback code is ran and a request is made to refresh the list.

We are using RavenDB and are experiencing ui problems with list items being deleted and then a new query being ran for the new list of items to be show and returned (in the same controller method)

Thanks as always
Ryan

@(Html.Telerik().Grid(Model)
        .Name("Grid")
        .DataKeys(keys => keys.Add(o => o.Id))
        .Columns(columns =>
        {
            columns.Bound(o => o.PartNumber).Width(100);
            columns.Command(commands =>
            {
                commands.Edit().ButtonType(GridButtonType.ImageAndText);
                commands.Delete().ButtonType(GridButtonType.ImageAndText);
            }).Width(200).Title("Commands");
        })
        .DataBinding(dataBinding => dataBinding.Ajax()
            .Select("_Index", "Gage")
            .Update("_Save", "Gage")
            .Delete("_Delete", "Gage"))
        .ClientEvents(events => events
            .OnSave("onSave"))
        .Groupable()
        .Sortable()
        .Pageable()
        .Editable(x => x.Mode(GridEditMode.PopUp))
        .Filterable()
    )
 
   
<script type="text/javascript">
 
    function onSave(e) {
         
    }
 
</script>

1 Answer, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 11 Apr 2011, 07:51 AM
Hello Ryan Black,

 Currently you cannot add a callback function which is executed after successful edit or delete. The event sequence is as follows:
  1. The user clicks the edit or delete button
  2. The OnEdit/OnDelete JavaScript event is raised
  3. If there are no validation errors (during editing) or the user confirms the delete a request to the server is made.
  4. The developer performs the update or delete and returns the updated data
  5. The grid is then rebound on the client side with the returned data unless there are ModelState errors. If there are errors the OnError event is raised.

Regards,
Atanas Korchev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
Grid
Asked by
Ryan Black
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Share this question
or