Custom Details Form Example

Hi,

Just wondering about the custom details form documented here: http://docs.dhtmlx.com/doku.php?id=dhtmlxscheduler:custom_details_form#custom_editors

There is no mention of how to save the data in the “Details” field. Is it possible to save this data? I can only figure out how to save data defined using sections like below:

scheduler.config.lightbox.sections=[ { name:"description", height:200, map_to:"text", type:"my_editor" , focus:true}, { name:"time", height:72, type:"time", map_to:"auto"} ]

Thanks

set_value method do all the job

get_value:function(node,ev){ //save additional data ev.location = node.childNodes[4].value; //return main data return node.childNodes[1].value; },

value which get_value method returns will be saved to the property , defined in the configuration of lightbox.

 { name:"description", height:200, map_to:"text"

so, second value will be saved to “text”

to do things a bit more simple, you can set any useless text as map_to attribute and set all values directly in get_value method, assigning them to properties of event object.

Hi and thanks for the reply.

I must be missing something. Here is what I have:

events.php

[code]<?php
include (’…/connector/scheduler_connector.php’);
include (’…/…/connector/config.php’);

$res=mysql_connect($server, $user, $pass);
mysql_select_db($db_name);

$scheduler = new SchedulerConnector($res,"MySQL");
//$scheduler->enable_log("log.txt",true);
$scheduler->render_table("job","id","start,finish,comments,status,est_cost");

?>[/code]

JS

[code]function initScheduler() {
scheduler.config.multi_day = true;
scheduler.config.first_hour = 4;
scheduler.config.last_hour = 21;
scheduler.config.details_on_dblclick=true;
scheduler.config.details_on_create=true;
scheduler.config.xml_date="%Y-%m-%d %H:%i";

scheduler.form_blocks["my_editor"]={
		render:function(sns){
			return "<div class='dhx_cal_ltext' style='height:60px;'>" +
					"Text&nbsp;<input type='text' maxlength='2'>" +
					"<br/>Details&nbsp;<input type='text'>" +
					"</div>";
		},
		set_value:function(node,value,ev){
			node.childNodes[1].value=value||"";
			node.childNodes[4].value=ev.est_cost||"";
		},
		get_value:function(node,ev){
			ev.location = node.childNodes[4].value;
			return node.childNodes[1].value;
		},
		focus:function(node){
			var a=node.childNodes[1]; a.select(); a.focus(); 
		}
	}
scheduler.config.lightbox.sections=[	
	{ name:"description", height:200, map_to:"text", type:"my_editor" , focus:true},
	{ name:"time", height:72, type:"time", map_to:"auto"},
	{ name: "status", height:30, type:"select", map_to:"status", options:[
         {key:"quote", label:"Quote"},
         {key:"scheduled", label:"Scheduled"},
         {key:"billed", label:"Billed"},
         {key:"complete", label:"Complete"}
         ]}
]

scheduler.init('job_scheduler',null,"day");

scheduler.load("dhtmlx/php/events.php?uid="+scheduler.uid());

var dp = new dataProcessor("dhtmlx/php/events.php");
dp.init(scheduler);

}[/code]

I must be missing the property defined in lightbox part.

get_value:function(node,ev){ ev.location = node.childNodes[4].value;

need to be changed as

get_value:function(node,ev){ ev.est_cost = node.childNodes[4].value;

Awesome. I’ll give it a go. Thanks greatly for the help.