simple question for Dhtmlx touch--- about properties.

Hi guys:
I just learnt Dhtmlx touch for few hours and now I have a simple question about properties.

I can set properties at beginning, but I cannot get properties value by code why?

For example,
this is my code,
id : “grid”,
view : “grid”,
header : true,
fields : [{
id : “Name”,
label : “Name”,
}, {
id : “email”,
label : “email”,
width: 400,
}],
dataType:“JSON”,
data:[
{Name:‘a’,email:“a@gmail.com”},
{Name:‘s’,email:“s.com”},
{Name:‘h’,email:“h.com”},

			]
				}]
			}]

Currently, I have already set the data as [{1},{2},{3}], this code is worked. Now I try to get grid’s data,I used
var strdata = $$(grid).data; however, strdata’s value is not
[
{Name:‘a’,email:“a@gmail.com”},
{Name:‘s’,email:“s.com”},
{Name:‘h’,email:“h.com”},
]
var strDatatype = $$(grid).datatype;
strDatatype’s value is unidentified.

why? why I cannot use gird’s properties directly.

Hi,

The item data can be got by item method:

var data = $$(“grid”).item(rowId);
var name = data.Name;
var email = data.email;

However, you did not define item ids:

data:[
{id:1,Name:‘a’,email:“a@gmail.com”},
{id:2,Name:‘s’,email:“s.com”},
{id:3,Name:‘h’,email:“h.com”}
]

If you do not want to set ids, you may get rowId that is automatically set by idByIndex method.

Yes, I know we can use item to get data’s value. However, If I need to get all the data from the grid, How can I get it?

You can use dataCount and idByIndex methods:

var gridData = []; for(var i=0; i< $$("grid").dataCount();i++){ var id = $$("grid").idByIndex(i); gridData.push($$("grid").item(id)); }