editorShape
Description
An array of objects containing settings for managing the appearance and functionality of the Editor dialogUsage
editorShape?: [
//common parameters for all types
{
key: string,
label?: string,
},
// for the "text" and "textarea" types
{
key: string,
label?: string,
type: "text" | "textarea",
config?: {
placeholder: string,
focus: boolean
}
},
// for the "combo", "select" and "multiselect" controls
{
key: string,
label?: string,
type: "combo" | "select" | "multiselect",
options?: {
id: any,
label?: string
}[],
config?: {}
},
// for the "slider" type
{
key: string,
label?: string,
type: "slider",
config?: {
width: number,
min: number,
max: number,
disabled: boolean,
step: number
}
},
// for the "date" type
{
key: string,
label?: string,
type: "date",
time?: boolean,
config?: {}
},
// for the "counter" type field
{
key: string,
label?: string,
type: "counter",
config?: {
min: number,
max: number,
}
},
// for the "link" type
{
key: string,
label?: string,
type: "links"
}
]
Parameters
To configure the editor appearance and functionality, you can specify the following parameters (fields):
Common parameters for all types
key
- (required) the name of the data field (from the task object). The value should be unique for each editor control type and correspond to the field name of the task object in the tasks property.label
- (optional) the label of the field controlconfig
- (optional) any configuration object for a control. It can have any property supported by related WX control (e.g. placeholder, focus, etc.)type
- (required) the editor field type. Here you can specify the following types: select, text, textarea, counter, date, slider, link
Parameters for the "text" and "textarea" types
type
- (required) the editor field type: text or textareakey
- (required) the name of the data field (from the task object): Text for the text control and Area for the textarea controllabel
- (optional) the label of the field controlconfig
- (optional) any configuration object for a control. The control types that accept it: text, select, combo, textarea, slider. It can have any property supported by related WX control (e.g. placeholder, focus, etc.). Here you can specify the following parameters:placeholder
- (optional) a placeholder valuefocus
- (optional) enables/disables the focusdisabled
- (optional) enables or disables the element
Example:
import React, { useRef } from "react";
import { getData } from "./common/data";
import { Gantt } from "wx-react-gantt";
const data = getData();
const editorShape = [
{
key: "Text",
type: "text",
label: "Name",
config: {
placeholder: "Task name",
focus: true,
},
},
];
function App() {
return (
<Gantt
tasks={data.tasks}
links={data.links}
scales={data.scales}
columns={data.columns}
editorShape={editorShape}
/>
);
}
export default App;
Parameters for the "combo", "select" and "multiselect" controls
type
- (required) the editor field type: "combo" | "select" | "multiselect",key
- (required) the name of the data field (from the task object): Combolabel
- (optional) the label of the field controloptions
- (optional) an array of objects with the next parameters for each option object: -id
- (required) the option IDlabel
- (optional) the label for an option
config
- (optional) any configuration object for a control. It can have any property supported by related WX control (e.g. placeholder, focus, etc.)
Example:
import { getData } from "./common/data";
import { Gantt } from "wx-react-gantt";
const data = getData();
const editorShape = [
{
key: "Combo",
type: "select",
label: "Type",
},
];
function App() {
return (
<Gantt
tasks={data.tasks}
links={data.links}
scales={data.scales}
columns={data.columns}
editorShape={editorShape}
/>
);
}
export default App;
Parameters for the "slider" type
type
- (required) the editor field type: sliderkey
- (required) the name of the data field (from the task object): Sliderlabel
- (optional) the label of the field controlconfig
- (optional) any configuration object for a control. The control types that accept it: text, select, combo, textarea, slider. It can have any property supported by related WX control (e.g. placeholder, focus, etc.). You can specify the following parameters:width
- (optional) slider width in pixelsmin
- (optional) min task progress in a percentage valuemax
- (optional) max task progress in a percentage valuedisabled
- (optional) enables or disables the slider; iffalse
(default), the slider is enabled
Example:
import { getData } from "./common/data";
import { Gantt } from "wx-react-gantt";
const GanttComponent = () => {
const data = getData();
const editorShape = [
{
key: "Slider",
type: "slider",
label: "Progress",
}
];
return (
<Gantt
tasks={data.tasks}
links={data.links}
scales={data.scales}
columns={data.columns}
editorShape={editorShape}
/>
);
};
export default GanttComponent;
Parameters for the "date" type
type
- (required) the editor field type: datekey
- (required) the name of the data field (from the task object): DatePickerstart_date
- (required) the start date keyend_date
- (required) the end date key
label
- (optional) the label of the field controltime
- (optional) set to true to show time; if false, time value is not shown
Example:
import { getData } from "./common/data";
import { Gantt } from "wx-react-gantt";
import React from 'react';
const App = () => {
const data = getData();
const editorShape = [
{
key: "DatePicker",
type: "date",
label: "Start date",
},
{
key: "DatePicker",
type: "date",
label: "End date",
},
];
return (
<Gantt
tasks={data.tasks}
links={data.links}
scales={data.scales}
columns={data.columns}
editorShape={editorShape}
/>
);
};
export default App;
Parameters for the "counter" type
type
- (required) the editor field type: counterkey
- (required) the name of the data field (from the task object): Counterlabel
- (optional) the label of the field controlconfig
- (optional) any configuration object for a control. The control types that accept it: text, select, combo, textarea, slider. It can have any property supported by related WX control (e.g. placeholder, focus, etc.) Here you can specify the following parameters:min
- (optional) min task duration value in daysmax
- (optional) max task duration value in days
Example:
import React, { useRef } from "react";
import { getData } from "./common/data";
import { Gantt } from "wx-react-gantt";
const GanttComponent = () => {
const data = getData();
const editorShape = [
{
key: "Counter",
type: "counter",
label: "Duration",
config: {
min: 1,
max: 100,
},
},
];
return (
<Gantt
tasks={data.tasks}
links={data.links}
scales={data.scales}
columns={data.columns}
editorShape={editorShape}
/>
);
};
export default GanttComponent;
Parameters for the "link" type
type
- (required) the editor field type: linkkey
- (required) the name of the data field (from the task object): links table
Default config
import React from 'react';
const FormComponent = () => {
return (
<form>
<div>
<label htmlFor="text">Name</label>
<input type="text" id="text" placeholder="Add task name" autoFocus />
</div>
<div>
<label htmlFor="details">Description</label>
<textarea id="details" placeholder="Add description"></textarea>
</div>
<div>
<label htmlFor="type">Type</label>
<select id="type"></select>
</div>
<div>
<label htmlFor="start">Start date</label>
<input type="date" id="start" />
</div>
<div>
<label htmlFor="end">End date</label>
<input type="date" id="end" />
</div>
<div>
<label htmlFor="duration">Duration</label>
<input type="number" id="duration" min="1" max="100" />
</div>
<div>
<label htmlFor="progress">Progress</label>
<input type="range" id="progress" />
</div>
<div>
<label htmlFor="links">Links</label>
<input type="url" id="links" />
</div>
</form>
);
};
export default FormComponent;