search envelope-o feed check
Home Unanswered Active Tags New Question
user comment-o

Drag and Drop from a TextBox or Grid

Asked by Anonymous
16 years ago.

Dear Dan!

I'm trying to drag a text from a Textbox or Grid cell to the Calendar:

<asp:TextBox ID=TextBox1 runat="server" onmousedown='return DayPilotCalendar.dragStart(this.Text, 60*30, "123", this.Text);'></asp:TextBox>

EventMove is invoked correctly, e.value, e.NewStart, e.NewEnd is OK, but e.Text is empty. Can you help me how to pass the text from the TextBox?

Thank you in advance.

Comment posted by Anonymous
16 years ago.

I would really like to drag and drop arow from a GridView. Can you please help me, how can I implement it?

Thank you

Comment posted by Dan Letecky
16 years ago.

As mentioned here (Drag&drop from an external source) the last parameter of dragStart() specifies the event text. You should modify your onmousedown attribute as follows:

onmousedown='return DayPilotCalendar.dragStart(this, 60*30, "123", this.value);'
If you want the TextBox to be removed after drop, keep the first "this", otherwise replace it with "null" (without quotes). "this.value" refers to the value of <input> element (that's the resulting HTML of TextBox).

GridView cell
To be able to drag from a GridView, you should use a TemplateField to render custom HTML. One of the ways to do it is here:

<asp:TemplateField HeaderText="Item">
<div onmousedown='return DayPilotCalendar.dragStart(this, <%# Eval("DURATIONINSEC") %>, <%# Eval("ID") %>, <%# Eval("TEXT") %>);'>
<asp:Label ID="LabelItem" runat="server" Text='<%# Eval("TEXT") %>'></asp:Label></div>
There might be some typos, especially in the double/single quotes combination, but you should get the idea. Let me know if there is any problem with this solution.
Comment posted by Anonymous
16 years ago.

Dear Dan!

Thank you very much for your quick and detailed answer. The only modification I had to do was adding double quotes to get the ID of the selected row in GridView:

onmousedown='return DayPilotCalendar.dragStart(null, 60*30, "<%# Eval("ID") %>", "" %>);'

I have an other problem: When dragging from the grid, everything becomes selected that is passed by the item beeing moved. I also send this message to you by e-mail attaching the screenshot. Do you have any idea how can I solve this problem?

Comment posted by Dan Letecky
16 years ago.
The selecting issue is fixed in the current code (it will be included in the next release).

A workaround is to add unselectable='on' attribute to all child elements of the element with onmousedown specified.
This question is more than 1 months old and has been closed. Please create a new question if you have anything to add.