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

How to send antiforgerytoken when getting information

5 Answers 287 Views
MultiColumnComboBox
This is a migrated thread and some comments may be shown as answers.
Eliel
Top achievements
Rank 1
Eliel asked on 16 Apr 2020, 05:28 PM

Hi, this may be a dummy question but I tried to use the .Data("forgerytoken") I got from the Grid examples but this obviously change the data adding a complex structure, I would like to keep the text property I got without the .Data

 

Thanks in advance.

5 Answers, 1 is accepted

Sort by
0
Accepted
Dimitar
Telerik team
answered on 20 Apr 2020, 10:27 AM

Hello Eliel,

The Data() method of the DataSource could be used to specify a JavaScript function that will be used to pass additional parameters along with a request. For example:

.Read(read => read.Action("Products_Read", "Grid").Data("additionalInfo"))

...

function additionalInfo() {
    return {
        name: "test",
        testParam: 2
    }
}

You could use this to pass any parameter of your choice along with the request. Then, those parameters could be accessed and processed in the server end-point:

public ActionResult Products_Read([DataSourceRequest] DataSourceRequest request, string name, int testParam) { ... }

I hope this helps. In case you have any additional questions, please let me know.

Regards,
Dimitar
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
0
Eliel
Top achievements
Rank 1
answered on 20 Apr 2020, 11:00 AM

Thanks for the answer, I would like to know if there is an easy way to get the text content or do I just simply get it with JS?

 

Thanks in advance!

 

/Eliel

0
Dimitar
Telerik team
answered on 21 Apr 2020, 05:48 AM

Hello Eliel,

If you are referring to a MultiColunComboBox, the related item could be retrieved with JS through the dataItem() method as follows:

var mc = $("#products").getKendoMultiColumnComboBox()
var item = mc.dataItem()

console.log(item);

Regards,
Dimitar
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
0
Eliel
Top achievements
Rank 1
answered on 21 Apr 2020, 06:59 AM

Just a side note: I just noticed that MultiColumnComboBox use GET instead of POST and therefore it is unnecessary (or not supported) send the AntiForgeryToken. 

Thanks for the help!

0
Dimitar
Telerik team
answered on 22 Apr 2020, 02:52 PM

Hello Eliel,

You could set the request to POST through the DataSource transport.read.type option to post:

.DataSource(datasource => {
  datasource => datasource.Read(r => r.Action("GetProducts", "Home").Type(HttpVerbs.Post)) 
})   

Regards,
Dimitar
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
Tags
MultiColumnComboBox
Asked by
Eliel
Top achievements
Rank 1
Answers by
Dimitar
Telerik team
Eliel
Top achievements
Rank 1
Share this question
or