Page Break and Page Merge
Page breaks and page merge features help survey authors manage the survey structure more quickly and efficiently. Use a page break to split a single survey page into two: simply drag the Page Break item from the Toolbox and drop it between two elements on the design surface. Conversely, the page merge option lets you combine two consecutive pages into one. To merge, select Page 2 or any subsequent page on the design surface and click the "Merge with previous page" button at the top of that page. The elements from the selected page will be appended to the previous one.
To implement the page breaks and page merge functionalities to Survey Creator, follow the steps below:
Create a custom
PageBreakclass.
Extend theQuestionclass and override thegetType()method.Register icons for the Page Break toolbox item and Page Merge action button.
Define SVG icons as string values and use theSvgRegistry.registerIcon(name, svg)method to register them.Handle the
onDragDropAllowandonQuestionAddedevents.
These events allow you to manage acceptable drop positions and split a page when users drag the Page Break item from the Toolbox onto the design surface.Add the Page Break toolbox item.
Pass anIQuestionToolboxItemobject to the Toolbox'saddItemmethod. Within this object, define the item's name and title, assign one of the icons registered on step 2, and specify a JSON object that this item produces.Add the Page Merge action button.
Handle theonElementGetActionsevent using a function. Within it, create and configure anIActionobject by specifying its ID, title, icon, visibility rules, and a function to execute when users click this button. Add theIActionobject to theoptions.actionsarray.
Refer to the Code tab to view the full code listing.