Form Editor control functions incorrectly after view change

After using showView to change views on a content object (e.g., a layout cell) that contains a form with an editor control, the editor control no longer functions correctly for entering, setting, and retrieving data. Here is the code for my test page (using v4.1.1 of DHTMLX Suite):

[code]

[/code]

Test 1:

  • Click “Change View” button twice to change view and then return to default view.
  • Cannot type into editor.

Test 2:

  • Enter text.
  • Click “Change View” button twice to change view and then return to default view.
  • Editor appears blank.
  • Click “Get Notes Value” button, it returns the text that was entered before changing view.

Test 3:

  • Repeat Test 2.
  • Click “Change Readonly” button.
  • Typed text appears, but cannot be edited, indicating Readonly mode has been turned on.

Test 4:

  • Repeat Test 3.
  • Click “Change Readonly” button again.
  • Text is now editable.
  • Alter text.
  • Click “Get Notes Value” button. Original text is returned.

Results for Tests 1-4 are the same when using the “Load Data” button instead of manually typing text.

Test 5:

  • On fresh page load, click “Change View” button twice.
  • Click “Load Data” button.
  • Click “Get Notes Value” button.
  • No data returned.

Test 6:

  • Repeat Test 5.
  • Click “Change Readonly” button.
  • Text disappears.
  • Click “Change Readonly” button again.
  • Enter text or click “Load Data”.
  • Click “Get Notes Value” button.
  • No data returned.
  • Click “Change Readonly” button again.
  • Text disappears again.

From the tests I’ve performed, my impression is that multiple editor documents are being created in the process of changing views, and that the editor control is keeping references to the original editor document which can no longer be interacted with by the user.

Hi

unforetunately this is browser’s behaviour to reset ‘content editable’ when editor moved through the DOM while you switch views. there are lots of custom cases when this can be occured that’s impossible to take them all into account.

please update the following code for your demo (rest code is the same):

if (name == "btnView") { if (layout.cells("a").getViewName() == "def") { // 1) first save editor's content editorBackupContent = form.getEditor("CompanyNotes").getContent(); // 2) then hide view with editor layout.cells("a").showView("new"); } else { // back order when you need to show editor // 1) show view layout.cells("a").showView("def"); // 2) call editor's minimal reinit form.getEditor("CompanyNotes")._prepareContent(); // 3) restore data from backup form.getEditor("CompanyNotes").setContent(editorBackupContent); } }

I tried to apply this to my project, but I was still having the same behavior. My page was building the form (actually two forms in two different views), then changing view immediately. When clicking on a record in a grid, it would load the appropriate view, then load the data into the form. After the data was loaded, I couldn’t access the editor value to be able to load it back in after doing the _prepareContent.

What I ended up doing instead is to use removeItem() and addItem() to recreate the Notes field before loading the data. That has fixed my issue for now. Thanks for looking into this, though!