KrisSodroski
KrisSodroski

Reputation: 2852

Knockout.SimpleGrid and nested objects

I have an object like this:

{
    "ObjectId": 20001,
    "Time": "2008-07-12T23:30:00",
    "NestedObject": {
        "NestedObjectId": 45,
        "ParameterName": "Heart Rate",

    }

}

My datamapping for SimpleGrid is simply:

 { headerText: "Object Id", rowText: "ObjectId" },
 { headerText: "NestedObject", rowText: "NestedObject.NestedObjectId" },
 { headerText: "Time", rowText: "Time" }

It does not bind NestedObject.NestedObjectId. Does anyone know if I'll have to extend knockout in order to get this functionality? Or is it built in?

Upvotes: 1

Views: 64

Answers (1)

nemesv
nemesv

Reputation: 139798

You can use a function as the parameter of the rowText:

{ 
    headerText: "NestedObject", 
    rowText: function (item) { return item.NestedObject.NestedObjectId; } 
}

Demo JSFiddle. (The sample were taken from here: Paged grid)

Upvotes: 1

Related Questions