EasyUI Forum
May 14, 2024, 04:19:46 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Dynamic options for datetimebox  (Read 8725 times)
eagleeye
Newbie
*
Posts: 19


View Profile Email
« on: June 24, 2015, 07:26:23 AM »

Hi partners i have one datagrid with one datetimebox and i need to send min and max  options but not fixed, like in my code.

My need is send dynamic values on min and max, the values for this are in json format and come from all data for datagrid, and  with it values i will pretend restrict date range of my datetimebox

Sample of json data for datagrid, fecha_min and fecha_max are my range date permitted on my datetimebox

Code:
{
    "total": "5",
    "rows": [
       
        {
            "id": "1015",
            "id_evento": "6",
            "id_usuario": "8",
            "rpe": "9M671",
            "solped": "500530548",
            "fecha_ini_prog": "19-05-2015 10:00",
            "fecha_fin_prog": "19-05-2015 12:00",
            "fecha_ini_real": "23-06-2015 10:00",
            "fecha_fin_real": "23-06-2015 12:00",
"fecha_min": "24-06-2015 13:00",
"fecha_max": "31-06-2015 13:00",
          "fecha_real_rango": "23-06-2015 10:00 | 23-06-2015 12:00",
            "duracion": "02:00:00",
            "titulo": "Acto de Apertura SBIE 500530548 LLANTA 11 R-22.5  LPI DIF. 1 18164039-003-15 \"B\"",
            "descripcion": "SBIE 500530548 LLANTA 11 R-22.5",
            "padre": "1",
            "evento": "APERTU",
            "desc_evento": "Acto de Apertura",
            "color": "#64FE2E"
        },
        {
            "id": "1016",
            "id_evento": "7",
            "id_usuario": "8",
            "rpe": "9M671",
            "solped": "500530548",
            "fecha_ini_prog": "22-05-2015 13:00",
            "fecha_fin_prog": "22-05-2015 14:00",
            "fecha_ini_real": "24-06-2015 13:00",
            "fecha_fin_real": "24-06-2015 14:00",
"fecha_min": "24-06-2015 13:00",
"fecha_max": "31-06-2015 13:00",
            "fecha_real_rango": "23-06-2015 13:00 | 23-06-2015 14:00",
            "duracion": "01:00:00",
            "titulo": "Evaluación Técnica SBIE 500530548 LLANTA 11 R-22.5 LPI DIF. 1 18164039-003-15 \"B\"",
            "descripcion": "SBIE 500530548 LLANTA 11 R-22.5",
            "padre": "0",
            "evento": "EVALUAT",
            "desc_evento": "Evaluación Técnica",
            "color": "#31B404"
        },
        {
            "id": "1017",
            "id_evento": "8",
            "id_usuario": "8",
            "rpe": "9M671",
            "solped": "500530548",
            "fecha_ini_prog": "22-05-2015 13:00",
            "fecha_fin_prog": "22-05-2015 14:00",
            "fecha_ini_real": "24-06-2015 13:00",
            "fecha_fin_real": "24-06-2015 14:00",
             "fecha_min": "24-06-2015 13:00",
             "fecha_max": "31-06-2015 13:00",
            "fecha_real_rango": "23-06-2015 13:00 | 23-06-2015 14:00",
            "duracion": "01:00:00",
            "titulo": "Evaluación Económica SBIE 500530548 LLANTA 11 R-22.5 LPI DIF. 1 18164039-003-15 \"B\"",
            "descripcion": "SBIE 500530548 LLANTA 11 R-22.5",
            "padre": "0",
            "evento": "EVALUAE",
            "desc_evento": "Evaluación Económica",
            "color": "#31B404"
        },
        {
            "id": "1018",
            "id_evento": "9",
            "id_usuario": "8",
            "rpe": "9M671",
            "solped": "500530548",
            "fecha_ini_prog": "26-05-2015 13:00",
            "fecha_fin_prog": "26-05-2015 15:00",
            "fecha_ini_real": "24-06-2015 13:00",
            "fecha_fin_real": "24-06-2015 15:00",
"fecha_min": "24-06-2015 13:00",
"fecha_max": "31-06-2015 13:00",
            "fecha_real_rango": "23-06-2015 13:00 | 23-06-2015 15:00",
            "duracion": "02:00:00",
            "titulo": "Fallo SBIE 500530548 LLANTA 11 R-22.5 LPI DIF. 1 18164039-003-15 \"B\"",
            "descripcion": "SBIE 500530548 LLANTA 11 R-22.5",
            "padre": "0",
            "evento": "FALLO",
            "desc_evento": "Fallo",
            "color": "#FFFFFF"
        },
        {
            "id": "1019",
            "id_evento": "10",
            "id_usuario": "8",
            "rpe": "9M671",
            "solped": "500530548",
            "fecha_ini_prog": "02-06-2015 14:00",
            "fecha_fin_prog": "02-06-2015 15:00",
            "fecha_ini_real": "24-06-2015 14:00",
            "fecha_fin_real": "24-06-2015 15:00",
"fecha_min": "24-06-2015 13:00",
"fecha_max": "31-06-2015 13:00",
            "fecha_real_rango": "23-06-2015 14:00 | 23-06-2015 15:00",
            "duracion": "01:00:00",
            "titulo": "Formalización del Contrato SBIE 500530548 LLANTA 11 R-22.5 LPI DIF. 1 18164039-003-15 \"B\"",
            "descripcion": "SBIE 500530548 LLANTA 11 R-22.5",
            "padre": "0",
            "evento": "FORMAL",
            "desc_evento": "Formalización del Contrato",
            "color": "#FFFFFF"
        }
    ]
}

Code:
<th field= "fecha_ini_real"    
                                            fixed="true"
                                            width="115" 
                                            align="center"                                             
                                            editor="{
                                            type:'datetimebox',
                                            options:{ 
                                            min:'21-06-2015', 
                                            max:'28-06-2015',
                                            disabled: false,
                                            editable:false,
                                            currentText:'Hoy',
                                            closeText:'Cerrar',
                                            okText:'Aceptar',
                                            showSeconds:false,
                                            onHidePanel:aumentaHora,
                                            onShowPanel:restringeRango
                                            }
                                            }">
                                            Fecha Inicio
                                        </th>

This is mi validator with fixed values

Code:
function restringeRango() {
    var row = $('#ejec_tt_eventos').datagrid('getSelected');
    //alert( row.fecha_ini_real );
    var opts = $(this).datetimebox('options');   
    $(this).datetimebox('calendar').calendar({
        validator: function (date) {
            var min = opts.parser(opts.min); // fixed value on datetimebox
            var max = opts.parser(opts.max); //fixed value on datetimebox
            if (min <= date && date <= max) {
                return true;
            } else {
                return false;
            }
        }
    });
}

Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #1 on: June 24, 2015, 09:01:51 AM »

When enter the editing mode, get the 'datetimebox' editor and then set the 'validator' function for the drop-down calendar object.
Code:
$('#dg').datagrid({
    onBeginEdit:function(index,row){
        var ed = $(this).datagrid('getEditor', {index:index,field:'fecha_ini_real'});
        if (ed){
            $(ed.target).datetimebox('calendar').calendar({
                min: row.fecha_min,
                max: row.fecha_max,
                validator: function (date) {
                    var opts = $(this).calendar('options');
                    var min = $.fn.datebox.defaults.parser(opts.min);
                    var max = $.fn.datebox.defaults.parser(opts.max);
                    if (min <= date && date <= max) {
                        return true;
                    } else {
                        return false;
                    }
                }
            })
        }
    }
})
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!