Cart Buy Licenses Contact Integrate into App Docs Support Login/Register
v 1.8.67
v 1.8.67
Overview Survey Creator Examples Docs Source Download

Override React Property Grid component

This example demonstrates how to override SurveyJS Creator react component.


                        
    
        Survey.StylesManager.applyTheme("modern");
    

class CustomPropertyGridWrapper extends React.Component {
    constructor(props) {
        super(props);
        this.btnClick = this.btnClick.bind(this);
    }
    btnClick() {
        alert("The Button is clicked");
    }
    render() {
        const model = this.props.model;
        if (!model) return null;
        const btnStyle = {margin: "20px", width:"100%", height: "32px"};
        return <div>
            <button onClick={this.btnClick} style={btnStyle}>Click me...</button>
            <SurveyCreator.PropertyGridComponent model={model}></SurveyCreator.PropertyGridComponent>
        </div>;
    }
}

SurveyReact.ReactElementFactory.Instance.registerElement("svc-property-grid", (props) => {
    return React.createElement(CustomPropertyGridWrapper, props);
});

            
                Survey.StylesManager.applyTheme("modern");
                let options = {
                // showTestSurveyTab: false,
                // showJSONEditorTab: false
                showLogicTab: true,
                showTranslationTab: true,
                showEmbeddedSurveyTab: true,
                };
                var creator = new SurveyCreator.SurveyCreator(options);
            
                
                    ReactDOM.render(
                    <React.StrictMode>
                        <SurveyCreator.SurveyCreatorComponent creator={creator} />
                    </React.StrictMode>,
                    document.getElementById("creatorElement")
                    );
                
;
                    
<!DOCTYPE html>
<html lang="en">
<head>
    <title>This example demonstrates how to override SurveyJS Creator react component., Survey Creator Example</title>

<meta name="viewport" content="width=device-width" />
        <script src="https://unpkg.com/react@17.0.1/umd/react.production.min.js"></script>
        <script src="https://unpkg.com/react-dom@17.0.1/umd/react-dom.production.min.js"></script>
        <script src="https://unpkg.com/@babel/standalone@7.2.5/babel.min.js"></script>
    <script src="/DevBuilds/survey-core/survey.core.min.js"></script>
    <script src="/DevBuilds/survey-react-ui/survey-react-ui.min.js"></script>
    <link href="/DevBuilds/survey-core/modern.min.css" type="text/css" rel="stylesheet" />
    <script src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.4.10/ace.min.js" type="text/javascript" charset="utf-8"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.4.10/ext-language_tools.js" type="text/javascript" charset="utf-8"></script>
    <!-- Uncomment to enable Select2
    <script src="https://unpkg.com/jquery"></script>
    <link href="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.3/css/select2.min.css" rel="stylesheet" />
    <script src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.3/js/select2.min.js"></script>
    -->
        <script src="/DevBuilds/survey-creator-react/survey-creator-react.min.js"></script>
        <link href="/DevBuilds/survey-creator-react/survey-creator-react.min.css" type="text/css" rel="stylesheet" />
    <link rel="stylesheet" href="./index.css">

</head>
<body>
    
<div id="surveyContainer">
        <div id="creatorElement" style="height: 100vh;"></div>
</div>

<script type="text/babel" src="./index.js"></script>

</body>
</html>