Single Select Field
The definition of the ISingleSelectField
type is as follows. To use it, you can use the following method:
const singleSelectField = await table.getField<ISingleSelectField>(fieldId);
const singleSelectField = await table.getField<ISingleSelectField>(fieldId);
The corresponding data types are:
type IOpenSingleSelect = {
id: string;
text: string;
};
type SingleSelectTransformVal = string | IOpenSingleSelect;
interface ISelectFieldOption {
id: string;
name: string;
color: number;
}
type IOpenSingleSelect = {
id: string;
text: string;
};
type SingleSelectTransformVal = string | IOpenSingleSelect;
interface ISelectFieldOption {
id: string;
name: string;
color: number;
}
createCell
createCell: (val: SingleSelectTransformVal) => Promise<ICell>;
createCell: (val: SingleSelectTransformVal) => Promise<ICell>;
Creates a cell for the single select field.
getCell
getCell: (recordOrId: IRecordType | string) => Promise<ICell>;
getCell: (recordOrId: IRecordType | string) => Promise<ICell>;
Gets the cell of the single select field for a given record.
setValue
setValue: (recordOrId: IRecordType | string, val: SingleSelectTransformVal) => Promise<boolean>;
setValue: (recordOrId: IRecordType | string, val: SingleSelectTransformVal) => Promise<boolean>;
Sets the value of the single select field for a given record.
getValue
getValue: (recordOrId: IRecordType | string) => Promise<IOpenSingleSelect>;
getValue: (recordOrId: IRecordType | string) => Promise<IOpenSingleSelect>;
Gets the value of the single select field for a given record.
addOption
addOption: (name: string, color?: number) => Promise<IFieldRes>;
addOption: (name: string, color?: number) => Promise<IFieldRes>;
Adds a new option to the single select field.
addOptions
addOptions: (optionList: { name: string, color?: number }[]) => Promise<IFieldRes>;
addOptions: (optionList: { name: string, color?: number }[]) => Promise<IFieldRes>;
Adds multiple new options to the single select field.
getOptions
getOptions: () => Promise<ISelectFieldOption[]>;
getOptions: () => Promise<ISelectFieldOption[]>;
Gets all the options of the single select field. The type definition of ISelectFieldOption
is as follows:
interface ISelectFieldOption {
id: string;
name: string;
color: number;
}
interface ISelectFieldOption {
id: string;
name: string;
color: number;
}
deleteOption
deleteOption: (idOrName: string) => Promise<IFieldRes>;
deleteOption: (idOrName: string) => Promise<IFieldRes>;
Deletes an option from the single select field by its ID or name.
setOption
setOption: (nameOrId: string, config: OptionConfig) => Promise<IFieldRes>;
setOption: (nameOrId: string, config: OptionConfig) => Promise<IFieldRes>;
Updates an option of the single select field by its ID or name. The type definition of OptionConfig
is as follows:
export type OptionConfig = {
name?: string;
color?: number;
};
export type OptionConfig = {
name?: string;
color?: number;
};
setOptionsType
setOptionsType: (type: SelectOptionsType) => Promise<IFieldRes>;
setOptionsType: (type: SelectOptionsType) => Promise<IFieldRes>;
Sets the option type of the single select field. The type definition of SelectOptionsType
is as follows:
enum SelectOptionsType {
STATIC, // Custom options
DYNAMIC, // Referenced options
}
enum SelectOptionsType {
STATIC, // Custom options
DYNAMIC, // Referenced options
}
getOptionsType
getOptionsType: () => Promise<SelectOptionsType>;
getOptionsType: () => Promise<SelectOptionsType>;
Gets the option type of the single select field. The type definition of SelectOptionsType
is as follows:
enum SelectOptionsType {
STATIC, // Custom options
DYNAMIC, // Referenced options
}
enum SelectOptionsType {
STATIC, // Custom options
DYNAMIC, // Referenced options
}