Available only in PRO Edition
이 뷰는 Scheduler PRO 버전에서만 사용할 수 있습니다.
Units 뷰는 X축을 단순히 시간 기준이 아닌, 이벤트의 특정 속성을 기준으로 구성합니다.
스케줄러에 Units 뷰를 추가하려면 다음 단계를 따르세요:
scheduler.plugins({
units: true
});
<div id="scheduler_here" class="dhx_cal_container" ...>
<div class="dhx_cal_navline">
...
<div class="dhx_cal_tab" name="unit_tab" style="right:280px;"></div>
</div>
...
</div>
//'unit_tab'은 div의 이름입니다
scheduler.locale.labels.unit_tab = "Unit"
scheduler.createUnitsView({
name:"unit",
property:"unit_id", // 유닛에 매핑할 이벤트 속성
list:[ // 뷰에 표시할 유닛 정의
{key:1, label:"Section A"},
{key:2, label:"Section B"},
{key:3, label:"Section C"}
]
});
Day, Month, Year와 같은 표준 뷰와 달리, Units와 Timeline과 같은 다중 리소스 뷰는 이벤트에 추가 필드가 반드시 필요합니다:
scheduler.createUnitsView({
name:"unit",
property:"unit_id",
list:[
{key:1, label:"Section A"},
{key:2, label:"Section B"},
{key:3, label:"Section C"}
]
});
scheduler.init('scheduler_here');
scheduler.parse([
{id:1, text:"Task1", start_date:"2019-09-17 12:00", end_date:"2019-09-18 21:00",
unit_id:"1"},
{id:2, text:"Task2", start_date:"2019-09-17 09:00", end_date:"2019-09-17 21:00",
unit_id:"3"},
{id:3, text:"Task3", start_date:"2019-09-17 15:00", end_date:"2019-09-18 15:00",
unit_id:"2"}
]);
이벤트는 unit_id 값과 list.key가 일치할 때 해당 유닛에 할당됩니다.
Units 뷰에서 유닛 목록을 동적으로 갱신하려면 serverList 및 updateCollection 메서드를 사용할 수 있습니다.
여러 날에 걸친 유닛을 표시하려면 days 파라미터를 사용하세요:
scheduler.createUnitsView({
name:"week_unit",
property:"section_id",
list:sections,
days:3 });
Related sample: Multiday Units view
이렇게 하면 두 번째 수평 스케일에 날짜가 표시됩니다.
두 번째 스케일의 포맷을 변경하려면 scheduler.templates[name+"_second_scale_date"] 템플릿을 사용하세요:
scheduler.templates.units_second_scale_date = function(date) {
return scheduler.templates.week_scale_date(date);
};
참고사항
scheduler.date.units_start = function (date) {
return scheduler.date.week_start(date);
};
버전 4.1부터 이벤트를 여러 유닛에 동시에 할당할 수 있습니다.
이 기능을 활성화하려면:
<script src="codebase/dhtmlxscheduler.js"></script>
<link rel="stylesheet" href="codebase/dhtmlxscheduler.css" type="text/css">
<script>
scheduler.plugins({
multisection: true, multiselect: true,
units: true
});
scheduler.config.multisection = true; scheduler.init('scheduler_here');
</script>
이후, 이벤트의 관련 속성에 여러 섹션(기본적으로 콤마로 구분, section_delimiter 참고)을 지정하면 해당 이벤트가 모든 유닛에 표시됩니다:
scheduler.createUnitsView({
name: "unit",
list: [
{key: 1, label: "James Smith"},
{key: 2, label: "John Williams"},
{key: 3, label: "David Miller"},
{key: 4, label: "Linda Brown"}],
property: "section_id", ...
});
scheduler.init('scheduler_here', new Date(2019, 5, 30), "unit");
scheduler.parse([
{ id:1, text:"Task A", section_id:'1', ...}, { id:2, text:"Task B", section_id:'1,3', ...}, { id:3, text:"Task C", section_id:'4', ...}, { id:4, text:"Task D", section_id:'2,3,4', ...}]);
Related sample: Multisection events in Timeline and Units view
X축에 표시되는 값은 list 파라미터로 설정합니다:
scheduler.createUnitsView({
name:"unit",
...
list:[
{key:1, label:"Section A"},
{key:2, label:"Section B"},
{key:3, label:"Section C"}
]
});
list의 각 항목에는 두 가지 필수 속성이 있어야 합니다:
서버에서 섹션 데이터를 불러오려면 다음을 사용하세요:
scheduler.createUnitsView({
name:"unit",
property:"type_id",
list:scheduler.serverList("units"),
size:20,
step:1
});
여기서 serverList가 'units'라는 리스트를 반환합니다.
load 메서드의 응답에 server list 이름의 컬렉션이 포함되어야 하며, JSON 형식은 다음과 같습니다:
{
"data":[
{
"id":"1",
"start_date":"2019-03-02 15:00:00",
"end_date":"2019-03-04 16:00:00",
"text":"Team meeting",
"type_id":"1"
},
{
"id":"2",
"start_date":"2019-03-02 17:00:00",
"end_date":"2019-03-04 18:00:00",
"text":"Strategy meeting",
"type_id":"2"
}
],
"collections": { "units":[ {"value":"1","label":"Conference room 1"}, {"value":"2","label":"Conference room 2"}, {"value":"3","label":"Conference room 3"} ] }}
또는 OptionsConnector 커넥터를 사용할 수 있습니다:
<?php
include('connector-php/codebase/scheduler_connector.php');//파일 포함
$res=mysql_connect("localhost","root","");//DB 서버 연결
mysql_select_db("sampleDB");//DB 연결. 'sampleDB'는 DB 이름
$list = new OptionsConnector($res, $dbtype);
$list->render_table("types","type_id","type_id(value),name(label)");
$scheduler = new schedulerConnector($res, $dbtype);
//클라이언트와 동일한 이름('units')을 사용합니다
$scheduler->set_options("units", $list);
$scheduler->render_table("events","id","start_date,end_date,text,type_id");
?>
dhtmlxConnector를 사용하지 않고 컬렉션을 직접 생성할 수도 있습니다. 이 경우 updateCollection 메서드로 컬렉션을 갱신하세요:
scheduler.updateCollection("units", new_sections_array);
Related sample: Loading Units sections from the server
유닛이 많을 경우 size 및 step 속성으로 수평 스크롤을 활성화할 수 있습니다:
scheduler.createUnitsView({
name:"unit",
...
size:10, // 한 번에 표시할 유닛 수
step:5 // 한 번에 스크롤할 유닛 수
});
Related sample: Horizontal scrolling sections in Units view
기본적으로 유닛에 매칭되지 않는 이벤트는 첫 번째 유닛에 표시됩니다. 3.0 버전부터는 이런 이벤트를 아예 건너뛸 수 있습니다.
이를 활성화하려면 skip_incorrect 속성을 설정하세요:
scheduler.createUnitsView({
name:"unit",
...
skip_incorrect:true
});