26
votes

We have a rendering listing the selected items in a TreeSelect in the current item. In our case we call them "Tags" (1)

We have added a Field Editor Button to the component to let the editor change selected items. (2) (As described on for example Adding a custom component)

When an editor clicks (2) the editor window (3) it is opened in a dialog. The editor may select different items(called tags in our case) using the TreeSelect.

When the editor presses the ok-button (4) the values are set.

Now to the problem:

The values are actually set as they get stored when the editor presses the Save button but we want our list on the page (1) to immediately reflect the set items when the editor presses the ok-button (4), i.e. before having to actually save the whole item.

How do we achieve that?

(I am in contacts with Sitecore support but so far I have not gotten any answers...)

Screenshot

Update After a lot of conversation with the support we still have no useful solution.

We tried turning it into a field renderer displaying the links. What worked was:

  • The field do get updated when you have edited it in the popup field editor. (but...)
  • It looks good the first time when page is loaded.
  • You can make a WebEdit button with commands to edit the field and add it as Custom button to the field (register <command name="webedit:fieldeditor" type="Sitecore.Shell.Applications.WebEdit.Commands.FieldEditor, Sitecore.Client"/> and set Click on the button to webedit:fieldeditor(command={3473DDA1-2983-493C-AF7A-054C75AA7AD3},fields=NameOfField where the guid points to itelf and an "Icon" is set on it.)

What didn't work was:

  • The field get updated by the raw value, not what I want to display. Server code is involved, but not in the rendering of html-code.
  • When I want to edit the value in the field editor, the value sent to the field editor is not the raw value but what actually is displayed on the page. (I guess this can be solved somehow)

The issue to the support turned into a feature request to let the server be involved in rendering the field, not just sending a new value to the JavaScript updating it. The server does the first rendering so when it already is involved in updating, it should be allowed to do the rendering the following times too.

We have decided to not spend more time on this right now (we have other things to do too.) and have a bad editor experience as the field not get updated until the editor actually saves the item.

Still we have no suitable solution for this issue. If you want to keep working on it and want a reference to my issue it is 439059.

1
In general the Sitecore Support team will only ask you to fill additional information when your ticket isn't 100% complete. My experience with the support department is that they (when info is complete) will always give you a suitable fix / solution to your problem.Younes
Yes, @Younes , most of the time the sitecore support gives good answers, but in this issue there have been several misunderstandings (both mine and their fault) that made me grumpy. ;-) So I thought I'll give the stackoverflow community the chance to produce an answer better/quicker. And when I get an answer more people should be able to read it.Erik Melkersson

1 Answers

1
votes

This may not be useful here. I've done this in normal sites, but not in Sitecore. But, here's one possibility....

This is a situation where you would pass a callback function to the child popup window. This callback will cause the caller / parent window to re-read/re-load the information that was just updated by the child.

Example: User presses (2) to open Editor Window(3) (Editor window is opened and the Callback function is passed as a parameter) User presses "OK" button (4). The "OK" button event handler updates the changes, then calls the Callback function which re-loads the now updated information, and closes the popup window. Once the popup closes, the parent window now displays the information that the popup/editor just updated.

This takes some client side javascript (jquery) development but it is quite do-able normally.