а

DataView: How to get properties of an item?


#1

Hi,

Suppose I have a DataView instance with items created according to a template, say “#name#
”.

Q: If I click on an item, how do I get its name?
I know DataView has a method “get( id )”, which returns an object (item) given its id, but then what? How to I get from this object the properties such as specified in the template, such as ‘name’ in this case?

Regards,
Bertwim


#2

I found the answer to my own question. Sharing it here so it might be of use to others.

Answer:
If the template is e.g. “#name#”, and the id of a DataView item is ‘id’, then the object
can be retrieved via var obj = dataview.get(id); // dataview = DataView instance.
Next, the “name” of the objected can be obtained simply via obj.name .

Straightforward, but you need to know …


#3

You also can find the example of the item properties getting on the following docs page:
docs.dhtmlx.com/api__dhtmlxdataview_get.html