Skip to content

Commit

Permalink
Added getVisible and getDisabled support
Browse files Browse the repository at this point in the history
  • Loading branch information
markcunninghamuk committed Nov 15, 2020
1 parent 071d8f9 commit 2a9391b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
11 changes: 10 additions & 1 deletion controls/pcfcontroldemo/MultiSelectControl/MultiSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import * as React from "react";
import AsyncSelect from 'react-select/async';

export interface IProps {
isControlVisible: boolean;
isControlDisabled: boolean;
displayValueField: any;
displayFieldLabel: any;
columns: any;
Expand Down Expand Up @@ -55,6 +57,8 @@ export class MultiSelectControl extends React.Component<IProps, IState> {
{
const selectStyles = { menuPortal: (zindex: any) => ({ ...zindex, zIndex: 9999}) };

if (this.props.isControlVisible)
{
return (
<div>
<AsyncSelect
Expand All @@ -65,8 +69,13 @@ export class MultiSelectControl extends React.Component<IProps, IState> {
getOptionValue={e => e[this.props.displayValueField]}
loadOptions={this.loadOptions}
defaultOptions
isDisabled={this.props.isControlDisabled}
onChange={this.onChange}
/></div>
);
)
}
else{
return (<></>);
};
}
}
7 changes: 6 additions & 1 deletion controls/pcfcontroldemo/MultiSelectControl/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ export class MultiSelectPCFControl implements ComponentFramework.StandardControl
columns: "",
topCount: "",
filterField: "",
entityName: ""
entityName: "",
isControlVisible: true,
isControlDisabled: true
};
private _context: ComponentFramework.Context<IInputs>;

Expand Down Expand Up @@ -77,6 +79,9 @@ export class MultiSelectPCFControl implements ComponentFramework.StandardControl

private renderElement()
{
this.props.isControlDisabled = this._context.mode.isControlDisabled;
this.props.isControlVisible = this._context.mode.isVisible;

ReactDOM.render(
React.createElement(MultiSelectControl, this.props)
, this._container
Expand Down

0 comments on commit 2a9391b

Please # to comment.