[ 3 posts ]

Rohit Shah

  • Username: masterrohitshah
  • Joined: Sat Jul 21, 2012 9:47 pm
  • Posts: 7
  • Offline
  • Profile

How to get datatable recordset in json string format.

Post Posted: Sun Jul 22, 2012 9:35 am
+0-
Hi,

I am new to the yui datatable. I want yui datatable recordset in json format.
I have written following code :

var rst1 = myDataTable.getRecordSet().getRecords();
var myJsonString = JSON.stringify(rst1);


which gives the output like :
[
{"_nCount":0,"_sId":"yui-rec11","_oData":
{"UOM_ID":6,"ITEM_DESC":"End Cover","ITEM_CODE":"99149","ITEM_ID":94}
},
{"_nCount":4,"_sId":"yui-rec15","_oData":
{"UOM_ID":6,"ITEM_DESC":"ValveHousing JT-S","ITEM_CODE":"11204","ITEM_ID":98}
}
]

and i want the output like :

{"data_DB":
[
{"UOM_ID":6,"ITEM_DESC":"End Cover","ITEM_CODE":"99149","ITEM_ID":94}
,{"UOM_ID":6,"ITEM_DESC":"End Cover","ITEM_CODE":"99150","ITEM_ID":95}
]
}

So please tell me how to convert that string to required format.

Thanks in advance...

Alberto Santini

YUI Contributor

  • Offline
  • Profile

Re: How to get datatable recordset in json string format.

Post Posted: Mon Jul 23, 2012 2:05 am
+0-
Hello Rohit.

In YUI 3 (this is a YUI 3 section) it would be:

myDataTable.data.toJSON();

You are using YUI 2. Any reason?

Hope that helps,
IceBox

Rohit Shah

  • Username: masterrohitshah
  • Joined: Sat Jul 21, 2012 9:47 pm
  • Posts: 7
  • Offline
  • Profile

Re: How to get datatable recordset in json string format.

Post Posted: Mon Jul 23, 2012 7:42 am
+0-
Thank you Alberto for your reply.
I will use YUI 3 datatable and let you know.
  [ 3 posts ]
Display posts from previous:  Sort by  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum