Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by cristhian on Jan 21, 2010 10:58
open dhtmlx forum
remind data

i have two select multiple en mi form_block
my question is how to remind or put the data selected in the second select(empleado) when make double click
in the event.

this is my code
scheduler.form_blocks["my_editor"]= {
        render:function(sns){
            return "<div class='dhx_cal_ltext' style='height:85px;'>"+
            "<select title='Personal de la Contraloría Municipal' multiple='multiple' name='equipoEmpleados' size='5' style='width:250px' id='equipoEmpleados'>"+
"<?php
    $empleados = getLideres();
    foreach($empleados as $lider){
        echo '<option value=\''.$lider['idEmpleado'].'\'';
        echo '>'.$lider['nombreCompleto'].'</option>';
    }
?>"+
"</select>"+
"<select multiple='multiple' name='empleado[]' size='5' style='width:250px; float:right' title='Integrantes del equipo de Auditoría' id='select_empleado'>"+
"<?php
$con= mysql_connect($servidor,$usuario,$contrasenia) or die (mysql_error());
mysql_select_db(BD_CYSA) or die(mysql_error());
$devuelve = $event_id;
    if($event_id!=0){    
        $query = "SELECT idEmpleado, CONCAT(aPaterno, ' ', aMaterno, ' ', nombre) AS nombreCompleto FROM $bd_Cont.$tb_Empleado JOIN ".BD_CYSA.".events_detalle USING(idEmpleado) WHERE event_id=".$event_id." ORDER BY aPaterno" or die (mysql_error());
        $result=mysql_query($query,$con) or die(mysql_error());
        while($linea=mysql_fetch_array($result)){
            echo '<option value=\''.$linea['idEmpleado'].'\'';
            if($idEmpleado==$linea['idEmpleado']){
                echo 'selected=\'selected\'';
            }
            echo '>'.$linea['nombreCompleto'].'</option>';
        }
    }
?>"+
            "</select>"+
            "<span style='float:right;text-align:center;'><input type='button' name='>>' value='>>' /><br />"+
"<input type='button' name='<<' value='<<' align='right' /><br /></span>"+
            "</div>";
        },
        
        set_value:function(node,value,ev){
            node.childNodes[1].length = 0;
            btns = node.childNodes[2].getElementsByTagName('input');
            btns[0].onclick = function onclick(event){ return swapSelect(node.childNodes[0], node.childNodes[1]); };
            btns[1].onclick = function onclick(event){ return swapSelect(node.childNodes[1], node.childNodes[0]); };
            scheduler.attachEvent("onEventSave",function(id,data){
                if(!ev.emple) ev.emple = [];
                var j = node.childNodes[1].options.length;
                for(i=0; i<j; i++){
                    alert(node.childNodes[1].options[i].value)
                    ev.emple[i] = node.childNodes[1].options[i].value;
                }
                return ev.emple;
            });
        },
    
        get_value:function(node,ev){ }        
    };
    
    
    scheduler.config.lightbox.sections=[    
        {name:"description", height:100, type:"textarea", map_to:"text", focus:true },
        {name:"custom", height:23, type:"select", options:sections, map_to:"idAuditoria" },
    {name:"detail", height:100, type:"my_editor", map_to:"auto", focus:false },
        {name:"type", height:21, type:"select", map_to:"event_type", options:[
            { key:0, label:"Urgente" },
            { key:1, label:"Normal" }
        ]},
        {name:"recurring", height:115, type:"recurring", map_to:"rec_type", button:"recurring"},
        {name:"time", height:72, type:"time", map_to:"auto"}
    ];
    
    scheduler.createUnitsView("unit","idAuditoria",sections);
    scheduler.config.multi_day = true;
        
    scheduler.init('scheduler_here', null, "year");
    scheduler.load("../modelo/m_scheduler_getData.php");
    var dp = new dataProcessor("../modelo/m_scheduler_getData.php");
    dp.setTransactionMode("POST", true);
    dp.enablePartialDataSend(true);
    //dp.setDataColumns([false,true,true,true]);
    dp.init(scheduler);
}    

scheduler.attachEvent("onBeforeLightbox",function(id){
    var ev = this.getEvent(id);
    var date = ev.start_date;
    return (date.getDay()&&date.getDay()!=6)
});

scheduler.attachEvent("onEventCreated",function(id){
    scheduler.getEvent(id).type = 0;
    return true;
});
scheduler.attachEvent("onEventAdded",function(id){
    var devuelve = this.getEvent(id);
return true;
});
Answer posted by Alex (support) on Jan 22, 2010 01:55

The editor values should be defined in the select_value method:

scheduler.form_blocks["my_editor"]= {

...

 set_value:function(node,value,ev){

document.getElementById("select_empleado").value = "some value here";

....

}

}

Answer posted by Stanislav (support on Jan 22, 2010 02:05
  You can strore values as

get_value:function(node,ev){
   var selects = node.getElementsByTagName("select");
   scheduler._save_for_future = selects[1].value; //or any other logic to save data
}

and reuse them later as


scheduler.attachEvent("onEventCreated",function(id){
   scheduler.getEvent(id).some_property = scheduler._save_for_future;
   return true; 
});
Answer posted by cristhian on Jan 22, 2010 08:30

thanks for the answer

but when get the id of event  i want save this id in $event_id for make the query in the select_empleado 

$con= mysql_connect($servidor,$usuario,$contrasenia) or die (mysql_error());
mysql_select_db(BD_CYSA) or die(mysql_error());
$devuelve = $event_id;
    if($event_id!=0){    
        $query = "SELECT idEmpleado, CONCAT(aPaterno, ' ', aMaterno, ' ', nombre) AS nombreCompleto FROM $bd_Cont.$tb_Empleado JOIN ".BD_CYSA.".events_detalle USING(idEmpleado) WHERE event_id=".$event_id." ORDER BY aPaterno" or die (mysql_error());
        $result=mysql_query($query,$con) or die(mysql_error());
        while($linea=mysql_fetch_array($result)){
            echo '<option value=\''.$linea['idEmpleado'].'\'';
            if($idEmpleado==$linea['idEmpleado']){
                echo 'selected=\'selected\''; 
          }
            echo '>'.$linea['nombreCompleto'].'</option>';
        }
    }
?>"+

Answer posted by Alex (support) on Jan 22, 2010 08:38

Sorry... the question isn't clear. What id do you want to save and where ?

 

Answer posted by cristhian on Jan 22, 2010 08:51

i want get the id of event created and save this id in my variable $event_id for make the query in the select multiple when i want update this event

"<select multiple='multiple' name='empleado[]' size='5' style='width:250px; float:right' title='Integrantes del equipo de Auditoría' id='select_empleado'>"+
"<?php
$con= mysql_connect($servidor,$usuario,$contrasenia) or die (mysql_error());
mysql_select_db(BD_CYSA) or die(mysql_error());

$event_id = put the id of event here 
    if($event_id!=0){    
        $query = "SELECT idEmpleado, CONCAT(aPaterno, ' ', aMaterno, ' ', nombre) AS nombreCompleto FROM $bd_Cont.$tb_Empleado JOIN ".BD_CYSA.".events_detalle USING(idEmpleado) WHERE event_id=".$event_id." ORDER BY aPaterno" or die (mysql_error());
        $result=mysql_query($query,$con) or die(mysql_error());
        while($linea=mysql_fetch_array($result)){
            echo '<option value=\''.$linea['idEmpleado'].'\'';
            if($idEmpleado==$linea['idEmpleado']){
                echo 'selected=\'selected\'';
            }
            echo '>'.$linea['nombreCompleto'].'</option>';
        }
    }
?>"+
            "</select>"+

Answer posted by Alex (support) on Jan 22, 2010 10:13
$event_id is php variable. id of the event in scheduler is javascript variable. You can send JS variable to the server using Ajax. If dataProcessor is used the information about new events is sent automatically.