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

how to run some JavaScript before and after "save"

3 Answers 676 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Robert
Top achievements
Rank 1
Robert asked on 04 Mar 2016, 10:46 PM

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!

3 Answers, 1 is accepted

Sort by
0
Vasil
Telerik team
answered on 07 Mar 2016, 02:17 PM
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
0
Robert
Top achievements
Rank 1
answered on 07 Mar 2016, 06:34 PM

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!

0
Vasil
Telerik team
answered on 09 Mar 2016, 08:55 AM
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
Tags
Grid
Asked by
Robert
Top achievements
Rank 1
Answers by
Vasil
Telerik team
Robert
Top achievements
Rank 1
Share this question
or