how to run some JavaScript before and after "save"

4 posts, 0 answers
  1. Robert
    Robert avatar
    37 posts
    Member since:
    Aug 2015

    Posted 04 Mar Link to this post

    I have two grids, A and B.

     

    After clicking on the save in A,

    1. Before passing to the server, I like to automatically calculate values and process some values before sending back to the server.

    2. if something wrong a message popup and don't send to the server

    3. if everything is good, have a modal popup about sending the data to the server

    4. after processing in the server, modal disappear

    5. after modal disappear, retrieve the data again from the server for grid B

     

    questions:

    1. I think I can use ".Events(e => e.Save("onSave"))" as before saving?

    2. Any event I should use for after saved?

    3. anyway I can pass the data back to the server which is not inside the grid when people click on grid save.

     

    thanks!

  2. Vasil
    Admin
    Vasil avatar
    1547 posts

    Posted 07 Mar Link to this post

    Hello Robert,

    You may want to handle the onRequestEnd event of the DataSource that Grid is using.

    .DataSource(dataSource => dataSource.Ajax(
        .Events(e => e.RequestEnd("onRequestEnd"))
    )

    function onRequestEnd(e) {
        if (e.type == "update") {
            if (e.response.Errors) {
              //show some alert
            }
            else{
              //refresh your second grid
            }
        }
    }

    Regards,
    Vasil
    Telerik
    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 Feedback Portal and vote to affect the priority of the items
  3. UI for ASP.NET MVC is VS 2017 Ready
  4. Robert
    Robert avatar
    37 posts
    Member since:
    Aug 2015

    Posted 07 Mar Link to this post

    Thanks a lot Vasil.

     

    Is there any way I can pass additional data back to the server which are not in the grid by using something like  ".Create("Editing_Create", "Controler1")" ?

     

    For example, I have two a dropdowns outside the grid which identifies the start and end rows. (The customers require these two dropdowns should be outside the grid instead of using radios inside the grid.) Therefore, How can I pass the grid data and these two dropdowns back to the server from .Create()/.Update()/.Destroy()?

     

    Thanks!

  5. Vasil
    Admin
    Vasil avatar
    1547 posts

    Posted 09 Mar Link to this post

    Hi Robert,

    Additional parameters can be passed using the transport.read.data parameter of the kendoDataSoruce.
    You should also add extra parameters to your action:
    public ActionResult Products_Read([DataSourceRequest] DataSourceRequest request, string p1, string p2, int p3) //...
    This is already discussed in our forums here:
    http://www.telerik.com/forums/pass-additional-parameters-to-read-ajax-datasource-method---mvc

    Regards,
    Vasil
    Telerik
    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 Feedback Portal and vote to affect the priority of the items
Back to Top
UI for ASP.NET MVC is VS 2017 Ready