Domanda

I've been working on a custom field, which contains a list. I have to be able to edit the selected item on the list in a richtext editor. (this is the only missing part).

I've read the topic on opening from c# code Opening Rich Text Editor in custom field of Sitecore Content Editor . This works nice for the "add" button, since i have to open the RTE empty(with default text...), but not for the Edit button.

My aproaches are:

  • Somehow in the Edit button's message field list:edit(id=$Target) pass the selected index (like list:edit(id=$Target,index=$SelectedIndex), but i don't know how to populate $SelectedIndex
  • Somehow in the overridden HandleMessage method get the list's selected index. I'm able to get the selected value Sitecore.Context.ClientPage.ClientRequest.Form[ID of list], but thats alone not much of a help, since i won't be able to decide which one to edit if two listitem equals.
  • Do the richtext editor opening and handling fully in javascript. As i saw at some script in content editor, i tried to do that, but i can't understand it clearly:

    richtext editor url:

    var page = "/sitecore/shell/Controls/Rich Text Editor/EditorPage.aspx";

    some params :

    var params = "?da=core&id&ed=" + id + "&vs=1&la=en&fld=" + id + "&so&di=0&hdl=H14074466&us=sitecore%5cadmin&mo";

    and the part where i'm not sure:

    var result = scForm.browser.showModalDialog(page + params, new Array(window), "dialogHeight:650px; dialogWidth:900px;");

    This way the RTE opens as expected (i guess i could get the selected index from javascript and pass it as a parameter later). However when i click ok, i get exception from EditorPage.js saveRichText function: Cannot read property 'ownerDocument' of null. Am i missing some parameter?

Either of the three aproaches is fine for me(also i'm open for new better ones) as soon as i'm able to do it. Thanks in advance!

Tamas

È stato utile?

Soluzione

I was able to enter some javascript into the message:

list:Edit(id=$Target,index='+document.getElementById(ID of the select using $Target ).selectedIndex+')

this way i got the index in HandleMessage.

I'm waiting for better solutions now.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top