How To Get DataView's Data

I’m surprised there is no method for getting a dataview’s data.

I have a json object, I use dataview.parse to create my dataview, I then manipulate the dataview by moving items up and down, NOW I need to call a single method to get the current dataviews data (preferably in json format). How do I go about getting this new data from my dataview?

I.e. if this item (you want do get data for it) is selected, you can call method “getSelected” to get a selected ID and then call for this ID method “get” - it returns has of data, related to this ID

No, not a single item, I want all the data for the entire dataview. Here is my setup…

var dvTemplate: { type:{ template:'html->template_container', padding:5, height:15, width:205 }}; var dvArray = [["some value 1","some labe 1"],["some value 2","some labe 2"],["some value 3","some labe 3"],["some value 4","some labe 4"],["some value 5","some labe 5"]]; view3 = myLayout3.cells("b").attachDataView(dvTemplate); view3.parse(dvArray, "jsarray");

Then on the page the user can move dataview items up, down, top, bottom, add items, and remove items.

When they are done I need to call a function to get the new data for the dataview. So for example, if they remove item1, and moved item2 to the bottom, I would like to call some function that would give me this…

[["some value 3","some labe 3"],["some value 4","some labe 4"],["some value 5","some labe 5"],["some value 2","some labe 2"]]

API approach is the next: use method dataCount() to get items number. Use it as item index in method idByIndex() to get and array with IDs. Push every item data in array via method get() iterating IDs.

You can write a right-method suggestion to get such functionality here:
viewforum.php?f=10

Your link above isn’t working.

Could you please add that request to next version? Something like .getAll([format]) format could be jsarray, xml, or json.

Thanks.

Ooops, sorry, link is fine.

For those this may help, I did what they suggested for now, it’s works, here is the code…

[code]var count = view3.dataCount();
var newData = [];

for (var i=0;i<count;i++)
{
var id = view3.idByIndex(i);
//The way below gives me wy more info than I need
//I simply want the two items, just like the array that I used initially
//newData.push([view3.get(id)]);
newData.push([view3.get(id).data0,view3.get(id).data1]);
}
//console.log(newData);

//refresh the main var that holds the data so I can redisplay the view later
dvArray = newData;[/code]

You are welcome!