submitting custom parameters in a Datasource using an everlive data type

5 posts, 0 answers
  1. Matt
    Matt avatar
    17 posts
    Member since:
    Jun 2015

    Posted 27 Aug 2015 Link to this post

    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        

                }
         });

     

  2. Matt
    Matt avatar
    17 posts
    Member since:
    Jun 2015

    Posted 27 Aug 2015 in reply to Matt Link to this post

    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

  3. Vasil
    Admin
    Vasil avatar
    19 posts

    Posted 31 Aug 2015 Link to this post

    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.
     
  4. Matt
    Matt avatar
    17 posts
    Member since:
    Jun 2015

    Posted 31 Aug 2015 in reply to Vasil Link to this post

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

     

    matt

  5. Vasil
    Admin
    Vasil avatar
    19 posts

    Posted 01 Sep 2015 Link to this post

    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.
     
Back to Top