Dataviewer - use of checkboxes and/or radio buttons

Dataviewer allows easiy display and editing of text fields.

Is it possible to use checkboxes and/or radio buttons to display and edit data within the dataviewer. If so, what is the syntax to use in the template and template-edit?

Do you want to have the checkbox in the edit state of the item or working checkbox in normal view of item?

In case of edit view, currently there is no ability to bind a single value to the group of checkbox|radios, but you can render any necessary checkboxes in template and use onAfterEditStart event to set checked state and onBeforeEditStop to save checked state back to variable.

In case of normal template with checkbox it can be achieved as

		data = new dhtmlXDataView({
			container:"data_container",
			type:{
				template:" <input type='checkbox' {common.checked()}> #Package# : #Version#<br/>#Maintainer#",
				checked:function(obj){
					return parseInt(obj.Version)>5 ? "checked" : "";
				},
				height:40
			}
		});
		
		data.attachEvent("onItemClick", function(id, ev, trg){
			if ((ev.target||ev.srcElement).tagName == "INPUT"){
				date.get(id).Version = 10;
				data.refresh(id);
				//dp.setUpdated(id, true, "updated");
				return false;
			}
		})

Above sample uses Version field to define check state, or course in real app it need to be replaced with some custom property.

Thanks Stanislav,

That checked.function construct basically did the trick. Just one small point for anyone trying this…
The line
date.get(id).Version = 10;
should be
data.get(id).Version = 10;

I wanted to show a disabled checkbox normally and an enabled checkbox in edit mode.
So the template for view mode includes:

<input name=‘mycheckbox’ type=‘checkbox’ {common.checked()} DISABLED>This is my checkbox

and in edit mode just leaves out the DISABLED attribute.