James
James

Reputation: 3184

Kendo UI - How to add request parameters to proxyURL?

According to the Kendo UI API, the pdf.proxyURL of kendo.ui.Grid will post a request with the following parameters:

How do I add parameters to this request?

In my case, I need to add CSRF param (i.e. _csrf.parameterName=_csrf.token) for Spring Security purposes.

Upvotes: 0

Views: 413

Answers (1)

Chao Luo
Chao Luo

Reputation: 2696

As I read the code in Kendo, It will add the CRSF token from meta automatically, So you just need put the token to meta in head

kendo.antiForgeryTokens = function() {
            var tokens = { },
                csrf_token = $("meta[name=csrf-token],meta[name=_csrf]").attr("content"),
                csrf_param = $("meta[name=csrf-param],meta[name=_csrf_header]").attr("content");

            $("input[name^='__RequestVerificationToken']").each(function() {
                tokens[this.name] = this.value;
            });

        if (csrf_param !== undefined && csrf_token !== undefined) {
          tokens[csrf_param] = csrf_token;
        }

    return tokens;
};

Or you can override the antiForgeryTokens function, and return a object, the object will be added before request the proxyURl.

Upvotes: 0

Related Questions