ASP.NET Ajax ReOrderList - Any way to disable specific items from being dragged and dropped? - asp.net

I have an ajax controltoolkit reorderlist within an asp.net application.
I need to disable certain specific steps from being reordered. This has to be done dynamically. All steps are consecutive and start from the beginning, but it's not known until runtime how many need to be disabled from being reordered any further.
I tried the e.item.enabled = false for reorderlist_itemdatabound but this just disabled links. I need to disable the drag handler.
Any help is greatly appreciated. Thanks!

To be honest, I'm not too familiar with this control, but...
You need to hide the drag handler div (or whatever is in the 'DragHandleTemplate' I believe) and/or change its class. Two suggestions:
1) Add a javascript startup script to disable the divs in question.
2) Subclass this control... Override the Render() method. Replace it with original code from ReorderList, but check the Item to see if you should render the drag handle.

as a workaround to disable drag'n'drop for some item - you can set width=0 to the control inside <DragHandleTemplate> </DragHandleTemplate>. Thus user won't be able to pick the item for dragging.

Suppose you have an image with id dragme in DragHandleTemplate; you can do this in the ItemDataBound handler:
Image dragMe = (Image)((TableRow)e.Item.Controls[0].Controls[0]).Cells[0].Controls[0].FindControl("dragMe");
dragMe.Style.Add(HtmlTextWriterStyle.Visibility, "hidden");
This way you preserve the alignment.

Related

Controlling div visibility from toggle buttons on another page

I am looking to control the visibility of a div on one page from a toggle button on an admin page. I have seen many examples of this being done on the same page but none that explain what it would look like to have this done from another page.
There are a number of ways to handle this. You should research what you want to do and then decide on a method that works best for you.
Personally I would look at a server-side implementation. In this way you can control the output to the client. You can use session variables for example. How this is done will depend on what language you are using.
If you only want a javascript solution then I can think of two options. First is to use cookies. You can then read the cookie and show/hide the div based on the value. This is what I would do.
Second you can pass in a querystring parameter and read it on the other page. Then hide/show your div. http://mysite.com/?div=hidden
If the admin page opened the child page using JavaScript then you can assign the window to a variable and control the contents through that variable. Like so:
var childWindow = window.open('some URL', options);
// now toggle the div in the child
var childDiv= childWindow.document.getElementById('your_div_id');
$(childDiv).toggle();

Does Flex fire an event after a chart is rendered in UI?

I am looking for an event which is fired (if any) after a chart is rendered (visible in UI) in Flash, we are using Flex SDK 3.0. We have to capture the screenshot after the chart is rendered, current implementation adds a huge delay in update_complete event callback, this is slowing down the whole job of generating images.
I tried to use EXIT_FRAME event, but this doesn't seem to serve the purpose. Any help to resolve this issue is highly appreciated.
Regards,
Dan
Adobe use this event : mx.events.FlexEvent.TRANSFORM_CHANGE
But if you want to use it, you are obligate to inherit from Chart Component classes. Take a look at DataTransform Class.
http://help.adobe.com/es_ES/FlashPlatform/reference/actionscript/3/mx/charts/chartClasses/DataTransform.html
I suggest you to look at the DisplayObject liveDoc, where there are several types of events. Some are fired before the rendering (Event.RENDER), some are fired after specific operation (ResizeEvent, for instance). But if you really want to know when you chart has been rendered, why don't you watch for the validation methods (updateDisplayList(), commitProperties()) by overriding them in a child class and fire a custom event in there ?

asp.net ListBox deselect item

I'm usting an asp:ListBox and I understand that to deselect items the user needs to hold down control while clicking on a selected item. Is there a way to make it that clicking on a selected item will deselect it without holding down control?
You can, but not in ASP.Net. You need to change the client-side HTML, meaning you need to code it using Javascript, to change the default behaviour or a select box. Something like:
<script>
function MyHandle(oSelect)
{
(change behaviuor here, using object oSelect)
return false;
}
</script>
<SELECT onclick="MyHandle(this)">
...
</SELECT>
But... I really recomend against it. To acheive what you want, your "MyHandle" function would have to emulate everything that normal forms does: selecting, de-selecting, range selecting (using shift), single selection without affecting others (control key), etc.
Its easier to switch to checkboxes, as Jakob suggested.
I don't think asp.net's listbox can do that out of the box (I think winform's listbox can) but you can set SelectionMode to Multiple and write javascript to achieve the behavior you require.

How can I implement drag-out-to-delete in Flex?

I have a List component from which I'd like to be able to remove items using drag & drop, but without having a specific target. If you use the mac, the behaviour I'm looking for is something like what the Dock uses; when you drag something out of the bounds of the control it should get an icon that indicates that it'll be deleted (OSX uses a cloud or something?) and then if you release it it will be removed from the list.
How can I do this?
(If I need to provide a more clear description, please comment; I'll fill in what I can)
In my experience with drag/drop in Flex, you cannot simply drag something out and handle that. There is no dragOut event (unfortunately), so that would leave you up to the task of writing dragOver and dragDrop listeners on all the containers surrounding your dragInitiator and handling the process accordingly.
It's more time consuming and can become complicated if any of these controls already have specific dragOver and dragDrop event handlers.
Hope this helps.
Having no Flex experience all I can offer is some psuedo code which resembles how I implemented a similar effect in JavaScript, but hopefully it will get you started.
Essentially what you'll want to do is during your drag event measure the current coordinates of the object you're dragging to see if they intersect the original container and when they fall outside of its bounds call the logic to update the icon in order to indicate it will be removed. Then, on the drop event, check the coordinates once more and delete the item if needed.

Flex/AS3 easy (I hope) drag and drop question - prevent dragging to other controls

I searched but couldn't find my answer, I'm sure it's easy for anyone with a little experience. I have multiple datagrids on a page, each one I want sortable with drag and drop, but I don't want items drug from one control to the other. How can I prevent a user from dragging an item out of a conrol. I would prefer to have it just stop moving with the mouse, but I am prepared to just completely cancel out of the dragging if need be.
I was trying to do something like this
dragExit="dragEvent.CANCEL"
This is obviously wrong, but I can't find the correct way to do it.
Thanks in advance.
~Mike
Ok, so you have an app with multiple drag/drop datagrids, and you only want items dragged within a datagrid, and not from 1 to the other, is how I understand this.
What you need to do is create a custom dragDrop event handler for each datagrid which has the following command: event.preventDefault(). This in effect will stop a datagrid from receiving items from another .
This does not prohibit the dragging an item outside its host's borders, but it will prohibit the item being dropped into a different datagrid.
HTH.

Resources