-
Notifications
You must be signed in to change notification settings - Fork 851
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Table Of Contents - Display a special mark within a page item when a page contains errors #7320
Comments
It is possible to display a special sign for a Table Of Contents page item using the Markdown feature. Here are main implementation steps.
import { Serializer } from "survey-core";
Serializer.addProperty("page", {
name: "errorMarkExists",
type: "boolean",
default: false
});
survey.onTextMarkdown.add((sender, options) => {
const el = options.element;
console.log(
"name: " +
options.name +
", text: " +
options.text +
", element type: " +
el.getType()
);
if (!el || el.getType() !== "page") return;
if (options.name === "navigationTitle") {
const page = el;
const pi = page.getProgressInfo();
const isCompleted = pi.questionCount === pi.answeredQuestionCount;
let hasErrors = false;
const questions = page.questions;
for (let i = 0; i < questions.length; i++) {
if (questions[i].errors.length > 0) {
hasErrors = true;
break;
}
}
let html = "";
if (hasErrors && !el.errorMarkExists) {
el.errorMarkExists = true;
} else if (!hasErrors && el.errorMarkExists) {
el.errorMarkExists = false;
}
if (el.errorMarkExists) {
if (options.text.indexOf("#") < 0) {
html = options.text + "#";
} else {
html = options.text;
}
} else {
html = options.text.replace("#", "");
}
if (!isCompleted) {
html = "<strong>" + html + "</strong>";
}
options.html = html;
}
}); Now, when a user attempts to complete a survey which contains errors, an error indicator appears within Table Of Contents. |
@JaneSjs i'm try to use above code but the Property 'locOwner' does not exist on type 'ILocalizableOwner' return this.model.owner.locOwner
|
i'm using angular platform , but see even if in your demo you see return this.model.owner.locOwner; "Property 'locOwner' does not exist on type 'ILocalizable Owner'.typescript(2339) " |
Hi @forat98,
Meanwhile, take note that this code uses non-documented API. We'll consider adding a public API for implelenting a custom item component. Thank you |
I'm encountering an issue when trying to create a custom component in my Angular application using SurveyJS. The error message is as follows: Can't create component with name: sv-custom-toc-item and default: undefined
|
User issue: T15426 - enable required panels/pages to ignore custom questions when validating
https://surveyjs.answerdesk.io/internal/ticket/details/T15426
Add an option to display some special mark within a page's title to inform users that a page contains errors.

The text was updated successfully, but these errors were encountered: