DataView setting a property value

Hi,

I want to set a value to specified property of a DataView object.

I need to use “onItemDblClick” event to do so. For some reason method view.set(id, {property:value}) does not do the job. I figure I need to do some special trick here?

Here’s the code:

[code] dataX = new dhtmlXDataView({
container: “data_container_X”,
type: {
// template: “

#EXPORT_TEMPLATE_TABLE_COMMENT#
#EXPORT_TEMPLATE_COLUMN_COMMENT#
#EXPORT_TEMPLATE_TABLE_NAME#
#EXPORT_TEMPLATE_COLUMN_NAME#
”,
template: “{common.exportTemplateTableComment()}{common.exportTemplateColumnComment()}{common.exportTemplateTableName()}{common.exportTemplateColumnName()}{common.exportOptionTableComment()}{common.exportOptionName()}{common.exportOptionExtraValue()}”,
exportTemplateTableComment:function( obj ){
if( typeof obj.EXPORT_TEMPLATE_TABLE_COMMENT != ‘undefined’ )
return “
” + obj.EXPORT_TEMPLATE_TABLE_COMMENT + “
”;

			return "";
		},
		
		exportTemplateColumnComment:function( obj ){
			if( typeof obj.EXPORT_TEMPLATE_COLUMN_COMMENT != 'undefined' )
				return "<div class='dhx_strong' style='height:8px;'>" + obj.EXPORT_TEMPLATE_COLUMN_COMMENT + "</div>";
				
			return "";
		},
		
		exportTemplateTableName:function( obj ){
			if( typeof obj.EXPORT_TEMPLATE_TABLE_NAME != 'undefined' )
				return "<div class='dhx_light technical'>" + obj.EXPORT_TEMPLATE_TABLE_NAME+ "</div>";
				
			return "";
		},
		
		exportTemplateColumnName:function( obj ){
			if( typeof obj.EXPORT_TEMPLATE_COLUMN_NAME != 'undefined' )
				return "<div class='dhx_light technical'>" + obj.EXPORT_TEMPLATE_COLUMN_NAME + "</div>";
				
			return "";
		},
		
		exportOptionTableComment:function( obj ){
			if( typeof obj.EXPORT_OPTION_TABLE_COMMENT != 'undefined' )
				return "<div class='dv_options'>" + obj.EXPORT_OPTION_TABLE_COMMENT + "</div>";
				
			return "";
		},
		
		exportOptionName:function( obj ){
			if( typeof obj.EXPORT_OPTION_NAME != 'undefined' )
				return "<div class='dhx_strong dv_options' style='height:8px;'>" + obj.EXPORT_OPTION_NAME + "</div>";
				
			return "";
		},
		
		exportOptionExtraName:function( obj ){
			if( typeof obj.EXPORT_OPTION_EXTRA_VALUE != 'undefined' )
				return "<div class='dhx_strong dv_options' style='height:8px;'>" + obj.EXPORT_OPTION_EXTRA_VALUE + "</div>";
				
			return "";
		},
		height: 48,
		width:175
	},
	x_count: 5,
	y_count: 2,
	drag:true
}); 

dataX.attachEvent("onItemDblClick", function (id, ev, html){
	var data = dataX.get( id );
	if( typeof data.EXPORT_OPTION_NAME != 'undefined' && data.EXPORT_OPTION_NAME.indexOf("...") > -1 ){
		var x = html.offsetLeft + html.offsetWidth;
		var y = html.offsetTop - 2 * html.offsetHeight;
		calWin = dhxLayout.dhxWins.createWindow("calWin", 100, 100, 228, 245);
		calWin.setPosition( x, y );
		calWin.setText("Pick a date");
		calWin.setIcon("calendar.png", "calendar.png");
		calWin.button("park").hide();
		calWin.button("minmax1").hide();
		calWin.button("minmax2").hide();
		calWin.denyResize();
		calWin.setModal(true);
		calObj = calWin.attachObject("calendar");
		myCalendar = new dhtmlXCalendarObject("calendar");
		myCalendar.setSkin('dhx_terrace');
		myCalendar.loadUserLanguage("pl");
		myCalendar.show();
		myCalendar.hideTime();
		
		myCalendar.attachEvent( "onClick",function( date ){
			var fullDate = date.getMonth() + 1;
			if( fullDate < 10 )
				fullDate = "0" + fullDate;
			fullDate = date.getFullYear() + "-" + fullDate + "-" + date.getDate(); 
			dataX.set( id, {EXPORT_OPTION_EXTRA_VALUE:fullDate});
			calWin.close();
		});
	}
	return false;
});[/code]

Hi,

try to use the following approach to update a certain property of an item:

dataX.item(id).EXPORT_OPTION_EXTRA_VALUE = fullDate;
dataX.refresh(id);

Ok, great - I think I needed the refresh() after the update :slight_smile:

Thank you Alexandra - good job! :slight_smile: