skip to Main Content

When kendo observable.get returns an object, it adds other properties such as uid and _events.

For example,

var observable = new kendo.data.ObservableObject();
var myCar = {make: "toyota", model: "camry"};
observable.set("car", myCar);
var carVar = observable.get("car");
console.log(carVar);

The console logs:

enter image description here

Working example is located here

How can I get the original object without the added properties?

2

Answers


  1. Try toJSON()

    console.log(carVar.toJSON());
    
    Login or Signup to reply.
  2. const observable = new kendo.data.ObservableObject();
    const myCar = {make: "toyota", model: "camry"};
    observable.set("car", myCar);
    const carVar = observable.get("car");
    

    You can either make a list of the relevant keys or get them from the original object like this:

    const keys = ["make", "model"];
    // or
    const keys = Object.keys(myCar);
    

    Here’s the code to get an object containing only entries for the original keys from the new object:

    keys.reduce((prev, current) => ({
        ...prev,
        [current]: extra[current]
    }), {})
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search