jQuery UI Widgets Forums Grid Unable to pass header values to API in virtual mode

This topic contains 1 reply, has 1 voice, and was last updated by  akadam 8 years, 1 month ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author

  • akadam
    Participant

    Hello,

    I am facing an issue in passing the http header value to the api. I checked the examples/demos online but it does not demonstrate my requirement.
    I have the following source object:

     var source =
            {
                datafields: [
                    { name: 'ProductIdentifier', type: 'string' },
                    { name: 'Name', type: 'string' },
                    { name: 'Description', type: 'string' }
                ],
                url: baseUrl + "Product/Get",
                datatype: "json",
                contentType: "application/json",
                type: "POST",
                pagesize: 5,
                beforeprocessing: function (data) {
                    source.totalrecords = data.TotalRecords;
                },
                formatdata: function (data) {
                    debugger;
                    var productSearchParameter = {
                        "PagingParameter": {
                            "PageIndex": data.pagenum + 1,
                            "PageSize": data.pagesize
                        },
                        "SortParameter": {
                            "SortColumn": "ProductName",
                            "SortOrder": 1
                        },
                        "SearchMode": 0,
                    };
                    return JSON.stringify(productSearchParameter);
                },
            };

    The productSearchParameter is fetched in the POST body, but along with it I also want to pass the TenantCode in the http header.
    I checked this demo but it does not mention anything about passing header in the api request.

    Please provide me suggestions to achieve this.


    akadam
    Participant

    I figured out a solution.
    Here it is,

    var dataAdapter = new $.jqx.dataAdapter(source,
                {
                    //Set the http header before calling the api.
                    beforeSend: function (jqXHR, settings) {
                        jqXHR.setRequestHeader('TenantCode', 'TenantCode');
                    }
                });
Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.