Edit this page

Kinvey

Kinvey is a complete BaaS that powers mission-critical applications and entire digital businesses.

Integration of CRUD Operations

Kinvey provides a ready-for-use API for CRUD operations which enables you to configure and integrate the following services with the Kendo UI widgets:

Important

To dynamically set the id of the data item, configure the URLs of all transport operations as functions.

For a demo on integrating all CRUD operations, refer to this Dojo example.

Read

The read service defined by the DataSource transport returns data in the expected JSON format. Depending on the setting, you might be required to provide an authorization token.

The following example demonstrates how to configure the read transport operation with an authorization token.

    var token = customToken
    // ...
    read: {
     url: function () {
      return "https://baas.kinvey.com/appdata/kid_ByXpkJIDb/books/"
     },
     type: 'GET',
     beforeSend: function (req) {
     req.setRequestHeader('authorization', token);
     }
    }

Update

The update service expects a PUT request that contains the id of the updated item as part of the URL. As a result, you need to programmatically add the id of the edited item to the URL on the save event of the widget—for example, on the save event of the Grid.

The following example demonstrates how to configure the update transport operation and add the id of the data item.

    var token = customToken
    var _id = 0;

    save: function (e) {
          _id = e.model._id
    },
    // ...
    update: {
     url: function () {
      return "https://baas.kinvey.com/appdata/kid_ByXpkJIDb/books/" + _id
     },
     type: 'PUT',
     beforeSend: function (req) {
      req.setRequestHeader('authorization', token);
     }
    }

Create

The create service defined by the DataSource transport creates a new item. If the _id of the item is not specified, the widget automatically generates and sends it as an empty string. As a result, you need to programmatically remove it from the request by using the parameterMap of the DataSource.

The following example demonstrates how to configure the create transport operation and remove the _id from the request.

    var token = customToken
    // ...
    create: {
     url: "https://baas.kinvey.com/appdata/kid_ByXpkJIDb/books",
     type: 'POST',
     beforeSend: function (req) {
     req.setRequestHeader('authorization', token);
     }
    }
    // Remove the _id parameter from the request

   parameterMap: function (options, operation) {
    if (operation == "create" && options._id == "") {
     delete options._id;
     return options;
    }
   }

Destroy

The destroy service submits the id of the data item that will be deleted and expects a DELETE request that contains the id of the item. As a result, you need to programmatically add the id of the edited item to the URL on the remove event of the widget—for example, on the remove event of the Grid.

The following example demonstrates how to configure the destroy transport operation and add the id of the data item.

    remove: function (e) {
     _id = e.model._id
    },
    //.....
    destroy: {
     url: function () {
       return "https://baas.kinvey.com/appdata/kid_ByXpkJIDb/books/" + _id
      },
      type: 'DELETE',
      beforeSend: function (req) {
       req.setRequestHeader('authorization', token);
      }
    }

See Also

Is this article helpful? Yes / No
Thank you for your feedback!

Give article feedback

Tell us how we can improve this article

close
Dummy