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

submitting custom parameters in a Datasource using an everlive data type

4 Answers 77 Views
Cloud Code
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Matt
Top achievements
Rank 1
Matt asked on 27 Aug 2015, 10:13 PM

Morning!  we have a cloud data table called InAppMessages.  i'm trying to submit some custom parameters from my client app when it reads its datasource attached to the everlive table so i can do some cloud data magic in the 'after read' functions using those parameters.

 

i haven't found any way to insert the custom parameters successfully into the header of my datasource.  i've tried making a transport: read function that uses ajax call per some other postings but i get a access key not valid error.  i tried modifying the header of the datasource using a custom transport read but just fails to run (errors in the app telling me the datasource doesn't exist).  i could post a bunch of code samples but i tried some significantly different approaches.  i figure this must be a well understood process but the documentation on the site did not work for me nor did any in postings.  i wanted to start this thread to get some recommended processes.

 

here's the first way i tried and what i thought should work:

custParams = {

"Age":36,
            "MemLevel":"Family"​

 var messageCenterDatasource = new kendo.data.DataSource({
            type: 'everlive',
            transport: {
                read: {

                   beforeSend: function (xhr) {
                                xhr.setRequestHeader("X-Everlive-​Custom-Parameters",  JSON.stringify(​custParams));
                   },
            },
            schema: {
                model: { id: Everlive.idField},
            },
            serverSorting: true,
            sort: {field: 'CreatedAt', dir: 'asc' },
            change: function(e) {
                //do stuff        

            }
     });

 

4 Answers, 1 is accepted

Sort by
0
Matt
Top achievements
Rank 1
answered on 27 Aug 2015, 10:15 PM

whoops...posted before i finished doctoring the code.  there is a missing }; at the end of the custParams section up top.  i did close the variable off...just didn't in this sample by accident.

 

any help is very welcome!  i've burned a few hours digging through instructions that aren't quite right and sometimes very misleading.

 

Matt

0
Vasil
Telerik team
answered on 31 Aug 2015, 09:32 AM
Hi Matt,

We have updated the way the Backend Services Datasource works. If you wish to add headers to a request operation (read, create, update, destroy) you can do it like so (notice the headers option):

custParams = {
    "Age":36,
    "MemLevel":"Family"
};
 var messageCenterDatasource = new kendo.data.DataSource({
            type: 'everlive',
            transport: {
                read: {
                   headers: {
                       "X-Everlive-​Custom-Parameters",  JSON.stringify(​custParams);
                   },
            },
            schema: {
                model: { id: Everlive.idField},
            },
            serverSorting: true,
            sort: {field: 'CreatedAt', dir: 'asc' },
            change: function(e) {
                //do stuff       
            }
     });

More information regarding the custom headers can be found in the official documentation:
http://docs.telerik.com/platform/backend-services/javascript/integrations/kendoui/kendoui-uidata-source

Please let me know if there is anything else I can help you with.

Kind regards,
Vasil
Telerik
 
Everlive is now Telerik Backend Services, and is part of the Telerik Platform.
 
0
Matt
Top achievements
Rank 1
answered on 31 Aug 2015, 04:48 PM

works like a charm.  thanks for updating the documentation, too.

 

matt

0
Vasil
Telerik team
answered on 01 Sep 2015, 11:35 AM
Hi Matt,

I am happy to hear that you've got this working.

Let us know if you have further questions.

Regards,
Vasil
Telerik
 
Everlive is now Telerik Backend Services, and is part of the Telerik Platform.
 
Tags
Cloud Code
Asked by
Matt
Top achievements
Rank 1
Answers by
Matt
Top achievements
Rank 1
Vasil
Telerik team
Share this question
or