Hello support,
I'm working on a project with this dependencies:
Code"survey-angular": "1.8.29",
"survey-creator": "1.8.29",
"survey-knockout": "1.8.29",
"survey-pdf": "1.8.29",
"surveyjs-widgets": "1.8.29",
"survey-core": "1.9.1",
"typescript": "~3.2.4"
I can't update to a more recent one, due to heavy customization (for example in that version tagbox didn't work as exptected and we have to implement a fix to it), so that's the first big issue.
The other one is that our solution implies forms with many pages, filled with many dropdowns: surveyjs tries to fill every dropdown of each page right after creating the survey (new Survey.Model( ... blabla... )
and that's how it usually works.
But we need to make the right calls only for those pages that are currently visible, or better, that are the current one, in order to improve the performance: consider that sometimes, when we're are reviewing a form which reached a final state and it's readonly, survey makes 50 to 60 http request, in order to fill ALL the dropdown for all the pages!
As you can see from the picture attached we are viewing the first page ("Tirocinante") but in the network tab you can spot too any HTTP calls make against services which populates dropdowns being visible in other pages as well ("Ospitante", "Tutor" and so on), while the first page has just 5-6 dropdowns.
I managed to find the right point in the code (or at least it's what I think) where I should stop the HTTP call, but somehow I can't prevent it:
Inside my survey.component.ts, inside ngOnInit I inserted these lines of code:
Codelet _this = this;
Survey.ChoicesRestfull.onBeforeSendRequest = function (sender: Survey.ChoicesRestfull, options) {
let currentPage = _this.utils.dot(sender, 'owner', 'loadingOwner', 'colOwnerValue', 'page', 'survey', 'currentPage');
let senderPage = _this.utils.dot(sender, 'owner', 'loadingOwner', 'colOwnerValue', 'page');
if (currentPage && senderPage && currentPage != senderPage)
{
options.request.abort();
return;
}
};
utils.dot is just a custom implementation of the dot syntax of latest versions of TS
I can reach that particular IF but surveyjs is making anyway the calls against the external services.
Is there a way (one at least or the correct one) to do so?
Thanks in advance,
Federico
Hello Federico,
When a survey is loaded, it initializes its elements. At this point, it fetches choices for all questions. A survey may have branching logic or some other functionality which requires survey elements to be ready by the time a survey appears on a page. However, once a survey makes a request and retrieves choices, these choices are cached. With these options, choices are further retrieved from the cache to avoid excessive HTTP requests. The Survey.settings.useCachingForChoicesRestful option is enabled by default in the modern version of a SurveyJS Form Library.
Unfortunately, it is impossible to somehow cancel choices retrieval - there is no cancellation flag within the sendRequest function of a ChoicesRestful object.
I may recommend that you check to ensure that choices cache is enabled in your application.
P.S. Please let me additionally clarify why you are not considering an upgrade? For the record: the modern version of SurveyJS libraries has a TagBox question available out of the box.
I look forward to your reply.