jQuery UI Widgets › Forums › Grid › Unable to pass header values to API in virtual mode
Tagged: API, grid, http header, source, virtualmode
This topic contains 1 reply, has 1 voice, and was last updated by akadam 8 years, 10 months ago.
-
Author
-
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
productSearchParameteris fetched in the POST body, but along with it I also want to pass theTenantCodein 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.
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'); } }); -
AuthorPosts
You must be logged in to reply to this topic.