Ranking Question with Custom Item Template
Ranking questions ask respondents to order an item list according to their preferences. If you want to customize the appearance of list items, enhance item styling, or create complex item layouts, you can implement a custom item template. This demo shows how a custom template can be used to add icons to ranking items.
To create a custom item template, follow the steps below:
Implement a component that renders item markup.
The component accepts the item configuration object as a prop. You can use itsvalue
andtext
properties to access the item's value to be saved in survey results and display text.Register the component so that it can be accessed by name.
In HTML/CSS/JavaScript projects, register the component inReactElementFactory
as shown in theindex.js
file.
In React, register the component inReactElementFactory
as shown in theSurveyComponent.jsx
file.
In Angular, register the component inAngularComponentFactory
as shown in thesurvey.component.ts
file.
In Vue and Knockout, use techniques native to these libraries:Assign the component name to the Ranking question's
itemComponent
property in the survey JSON schema.