1

I'm having a problem with ZK binding and drag and drop feature. I have two listboxes:

<listbox id="left" width="100%" model="@load(vm.contacts)" height="200px" draggable="true" droppable="true" onDrop="@command('move')">                      
    <listhead>
        <listheader label="Contatto" align="center"  />
    </listhead>
    <template name="model" var="contact">
        <listitem value="@bind(contact)" draggable="true" droppable="true" onDrop="@command('move')"> 
           <listcell src="/img/contact-icon_x32.jpg" label="@load(contact.person.surname.concat(' ').concat(contact.person.name))" />
        </listitem>
    </template>
</listbox>
...
<listbox width="100%" id="right" model="@load(vm.contactsQuickKey)" height="250px" draggable="true" droppable="true" onDrop="@command('move')" >
    <listhead>
         <listheader label="Etichetta" align="center"  />
         <listheader label="Contatto" align="center"  />
    </listhead>
    <template name="model" var="contactQuickKey">
         <listitem value="@bind(contactQuickKey)" draggable="true" droppable="true" onDrop="@command('move')">
             <listcell>                                   
                 <textbox width="90%" value="@load(contactQuickKey.label) @save(contactQuickKey.label, before={'move', 'saveData', 'setLeftActivePage'})"/>
             </listcell>
             <listcell src="/img/contact-icon_x32.jpg" label="@load(contactQuickKey.contact.person.surname.concat(' ').concat(contactQuickKey.contact.person.name))" />
         </listitem>
    </template>
</listbox>

If I edit the textbox in the right listbox and then immediately, without clicking anywhere, I drag and drop a cell from the left one, the text I added disappears. The only way I can save the text is to use an onchange event, but it is very heavy.

EDIT: I created a working demo here http://zkfiddle.org/sample/2t6r27o/24-drag-and-drop-test

Does anyone can give me a better solution?

Thank you very much!

SOLUTION

I added the "instant="true"" to the textbox and this solved my problem!

Thanks to all of you how helped me!

4

2 回答 2

2

instant="true" 解决方案是将放到 textbox中。这解决了通过拖放丢失文本修改的问题。

于 2013-05-14T13:08:39.633 回答
1

您的问题是,您的文本未加载到 serversideTextbox中。
您在 drop by 之前保存before={'move'...但无法将其加载到
Textbox因为这需要 a notifyChange,在执行之前已满
@command('move'),这是不可能的,因为 zk执行周期的原因以及导致保存
的事实move

您可以做的是,在命令中从您的 vm 类中Textbox的数据中手动更改。但是找出被拖动的实例属于 哪个实例可能是个问题。
move
contactQuickKeyTextbox

顺便问一下,onChanging 的问题在哪里?流量不应该是一个。

编辑

由于某种原因,数据不会在move命令之前保存,如果
不是在拖动之前发生另一个用户操作。
也许是一个错误?

于 2013-05-13T16:50:59.667 回答