Lightbox changing and multiselect

Hi.
I’m trying to change lightbox view displayed from Scheduler double clicked by Month/Week/Unit View refer to the below URL.
viewtopic.php?f=6&t=3469
It works!
But selectbox and multiselect loading from db is not work…

Please tell me how about… :cry:

Hello,

Please describe your problem in detail (sorry, probably didn’t get it) and also provide your code.

Also be sure to reset lightbox (scheduler.resetLightbox():wink: after you’ve changed it’s section configuration.

Kind regards,
Ilya

Hello Ilya.
Thank you for a quick reply. Sorry I can’t reply sooner to you.

First, I’m try to work this scheduler in CAKEPHP & MySQL. Since, my code is divided into ‘View’ and ‘Model’ and ‘Controller’.

I want to change lightbox display according to the double-clicked position.
Lightbox A from Month view, lightbox B from Week view, and lightbox C from Unit view.
Lightbox A is hospital schedule, lightbox B is shopping schedule, lightbox C is Daily study schedule.

It was success below code(in ‘View’ file : schedule.ctp ):

var catlist = [
  {key:0, label:"--Please select--"},
  {key:1, label:"Hospital"},
  {key:2, label:"Shopping"},
  {key:3, label:"Study"}	
];
var schedule_sections=[
  {key:10, label:"English"},
  [key:20, label:"Math"},
  {key:30, label:"Science"},
  {key:40, label:"Geography"}
];
var secondsections=[
  {key:10, label:"food"},
  [key:20, label:"clothes and shoes"},
  {key:30, label:"drug store"},
  {key:40, label:"book and games"}
];

scheduler.attachEvent("onBeforeLightbox",change_lightbox);

function change_lightbox(id){
  var ev = this.getEvent(id);
  var tmpmode = scheduler.getState().mode;
  var sectiontype = 'default';
  switch (tmpmode){
    case 'Month':
      scheduler.config.lightbox.sections = [
        {name:"time", height:72, type:"calendar_time", map_to:"auto"},
        {name:"description", height:200, map_to:"text", type:"textarea" , focus:true},
        {name:"category", height:21, map_to:"schedule_category_id", type:"select", options:catlist},
        {name:"memo", height:200, map_to:"memo", type:"textarea" , focus:true}
      ];
      break;        
    case 'Week:
      scheduler.config.lightbox.sections = [
        {name:"time", height:72, type:"calendar_time", map_to:"auto"},
        {name:"description", height:200, map_to:"text", type:"textarea" , focus:true},
        {name:"category", height:21, map_to:"schedule_category_id", type:"select", options:catlist},
        {name:"section", height:21, map_to:"schedule_section_id", type:"radio", options:secondsections},
        {name:"memo", height:200, map_to:"memo", type:"textarea" , focus:true}
      ];
      break;
    case 'Unit':
      scheduler.config.lightbox.sections = [
        {name:"time", height:72, type:"calendar_time", map_to:"auto"},
        {name:"description", height:200, map_to:"text", type:"textarea" , focus:true},
        {name:"category", height:21, map_to:"schedule_category_id", type:"select", options:catlist},
        {name:"section", height:21, map_to:"schedule_section_id", type:"radio", options:schedule_sections},
        {name:"memo", height:200, map_to:"memo", type:"textarea" , focus:true}
      ];
      break;
    default:
  }
  scheduler.resetLightbox();
  return true;
}

scheduler.createUnitsView({
  name:"unit",
  property:"schedule_section_id",
  list:schedule_sections
});

scheduler.setLoadMode("month");
scheduler.load("/scheduler_event");
var dp = new dataProcessor("/scheduler_event");
dp.init(scheduler);

Next, multiselect checkbox add to case ‘Week’ in ‘View’ file, success :

var thirdsections = [
  {key:1, label:"milk"},
  {key:2, label:"butter"},
  {key:3, label:"bread"}  
];

{name:"foodcheck", height:22, map_to:"food_id", type:"multiselect", options:thirdsections, script_url: '', vertical:"false" }

And, I think, I would like to call those list from db.
In db, create those tables, and I wrote below code in ‘Controller’ file : SchedulerController.php:

*below ‘ComScheduleCategory’ is table Model.

//By before createUnitView, use list(schedule_sections) should created?
public function scheduler(){
  $status = array(
    'fields' => array('id','category_name'),
    'conditions' => array('delete_flg'=>'0')
  );
  $arrCKind = $this->ComScheduleCategory->find('all',$status);
  $this->set('arrCKind',$arrCKind);
}

public function scheduler_event(){

$categorylist = new OptionsConnector($res);
$sql = "Select *,category_name as label,id as value from study_categories where delete_flg=0";
$categorylist->render_sql($sql,"id","value,label");
$scheduler->set_options("category", $categorylist);
}
$categorylist2 = new OptionsConnector($res);
$sql = "Select *,category_name as label,id as value from schedule_categories where delete_flg=0";
$categorylist2->render_sql($sql,"id","value,label");
$scheduler->set_options("catlist", $categorylist2);
}
$categorylist3 = new OptionsConnector($res);
$sql = "Select *,category_name as label,id as value from shop_categories where delete_flg=0";
$categorylist3->render_sql($sql,"id","value,label");
$scheduler->set_options("category3", $categorylist3);
}
$categorylist4 = new OptionsConnector($res);
$sql = "Select *,category_name as label,id as value from food_categories where delete_flg=0";
$categorylist4->render_sql($sql,"id","value,label");
$scheduler->set_options("foodlist", $categorylist4);
}
$scheduler->render_table("schedules","id","start_date,end_date,details,schedule_category_id,schedule_section_id,schedule_catlist_id,rec_type,event_pid,event_length");
}

Last, in ‘View’ file (schedule.ctp), select and multiselect sections option rewrite below:

        {name:"category", height:21, map_to:"schedule_category_id", type:"select", options:catlist},

        {name:"section", height:21, map_to:"schedule_section_id", type:"radio", options:secondsections},

        {name:"foodcheck", height:22, map_to:"food_id", type:"multiselect", options:thirdsections, script_url: '', vertical:"false" }

to

        {name:"category", height:21, map_to:"schedule_category_id", type:"select", options:scheduler.serverList('catlist)},               			

        {name:"section", height:21, map_to:"schedule_section_id", type:"radio", options:scheduler.serverList('category3)},    

        {name:"foodcheck", height:22, map_to:"food_id", type:"multiselect", options:scheduler.serverList("food_id"), script_url:"/scheduler_event", vertical:"false" }

But not work… :cry:

To trial, nouse “onBeforeLightbox” pattern is success.

Thank you for offering a good tool.
And thank you reading my awkward English long long text :slight_smile:

Kind regards,
Misaki

Oh sorry, I’m mistake.

It’s negative:
{name:“foodcheck”, height:22, map_to:“food_id”, type:“multiselect”, options:scheduler.serverList(“food_id”), script_url:"/scheduler_event", vertical:“false” }

It’s correct:
{name:“foodcheck”, height:22, map_to:“food_id”, type:“multiselect”, options:scheduler.serverList(“foodlist”), script_url:"/scheduler_event", vertical:“false” }

Hello.

So like can not get the answer, I decided to export it to a static array in javascript and pass to multiselect & select section to give up.

Thank you.