0

In my project, we are using survey JS for filling forms in angular application. In Survey Matrix , the default date picker is jQuery UI Date picker. It is hard to use as it does not have ease of year access navigation and other features. I would like to use Bootstrap date picker which is better than this default one. But I am unsure how I can invoke this custom widget whenever I select the date picker cell type in Matrix. I have referred the below URL https://surveyjs.io/Examples/Library/?id=custom-widget-datepicker&platform=Angular#content-js and it has example of how to display date picker type and not sure how I can inject this into Matrix. Any help is much appreciated.

Viswa
  • 745
  • 10
  • 30

1 Answers1

1

Before using the bootstrap datepicker please make sure you have added the following scripts and stylesheets, just before the surveyjs-widgets.min.js file:

...
    <script src="https://unpkg.com/moment@2.24.0/moment.js"></script>
    <link rel="stylesheet" href="https://unpkg.com/bootstrap@3.3.7/dist/css/bootstrap.min.css">
    <script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.9.0/js/bootstrap-datepicker.js"></script>
    <link href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.9.0/css/bootstrap-datepicker.min.css" type="text/css" rel="stylesheet"/>
...
    <script src="https://unpkg.com/surveyjs-widgets@1.8.64/surveyjs-widgets.min.js"></script>

After that you can specify the custom widget column type for your matrix like so:

var json = {
    questions: [
        {
            type: "matrixdynamic",
            name: customDateMatrix",
            title: "Bootstrap date picker example",
            addRowText: "Add Date",
            columns: [
                {
                    name: "theDate",
                    "cellType": "bootstrapdatepicker",
                    "dateFormat": "mm/dd/yy",
                    title: "Pick a date"
                }
            ],
            rowCount: 1
        }
    ]
};

Here's a version of the custom widget matrix example with the bootstrap picker in the second column: https://plnkr.co/edit/BLzBzlMwuLEUaLn5

Oggy
  • 1,516
  • 1
  • 16
  • 22