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

how can i get the pure json data of the selected row

2 Answers 1028 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Chris
Top achievements
Rank 1
Chris asked on 12 Apr 2012, 09:36 AM
I create a Grid using kendoGrid :), here is the code for getting the selected row's data

var tr = $("#productGrid").find("tbody tr.k-state-selected");
var product = $("#productGrid").data("kendoGrid").dataItem(tr);
for(var o in product){
    if(product.hasOwnProperty(o)){
        //do something with o ..
        //Here i found o has properties like: _events,uid
        /*
        product
          o.extend.init
            _events: Object
            test0: o.extend.init
            test1: o.extend.init[2]
            test2: "string"
            test3: "string"
            uid: "b5494c4b-c89d-4139-885d-b376933f17bd"
            __proto__: y.extend.b
        */
        //It may have trouble when i want to do something with o
    }
}

so, what should i do to get the pure product object without the properties: _events , uid..


since my native language is not English, please forgive my grammar errors :)

2 Answers, 1 is accepted

Sort by
0
Accepted
Nikolay Rusev
Telerik team
answered on 12 Apr 2012, 11:34 AM
Hello Chris,

You can call toJSON method of the ObservableObject, i.e:
var product = $("#productGrid").data("kendoGrid").dataItem(tr).toJSON();


Regards,
Nikolay Rusev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Chris
Top achievements
Rank 1
answered on 12 Apr 2012, 05:14 PM
Thanks :)
Tags
Grid
Asked by
Chris
Top achievements
Rank 1
Answers by
Nikolay Rusev
Telerik team
Chris
Top achievements
Rank 1
Share this question
or