Move items up and down

I am trying to create the spry based mechanism to move
selected items either up or down. I have drop down and 2 buttobns
up and dwon how can i incorporate this in spry. I have this working
JS. But how about spry.
function Field_up(lst) {
var i = lst.selectedIndex;
if (i>0) Field_swap(lst,i,i-1);
function Field_down(lst) {
var i = lst.selectedIndex;
if (i<lst.length-1) Field_swap(lst,i+1,i);
function Field_swap(lst,i,j) {
var t = '';
t = lst.options
.text; lst.options.text = lst.options[j].text;
lst.options[j].text = t;
t = lst.options
.value; lst.options.value = lst.options[j].value;
lst.options[j].value = t;
t = lst.options
.selected; lst.options.selected = lst.options[j].selected;
lst.options[j].selected = t;
t = lst.options
.defaultSelected; lst.options.defaultSelected =
lst.options[j].defaultSelected; lst.options[j].defaultSelected = t;
function SetFields(lst,lstSave) {
var t;
lstSave.value=""
for (t=0;t<=lst.length-1;t++)
lstSave.value+=String(lst.options[t].value)+",";
if (lstSave.value.length>0)
lstSave.value=lstSave.value.slice(0,-1);
}

What happens when you run it?  Does the drag start?  Does it drop?
If you have a sort applied to the collection you won't be able to rearrange items.
Alex Harui
Flex SDK Developer
Adobe Systems Inc.
Blog: http://blogs.adobe.com/aharui

Similar Messages

  • Moving items up and down in a JList

    Hello I posted this query in the wrong forum and so now I am trying to correct the problem Here is the link
    http://forum.java.sun.com/thread.jspa?threadID=5267663&tstart=0
    Hi-
    I have a problem with moving selected items up and down in a JList..
    When I select an item in the JList and press ctrl + (the up or down arrow key),
    I want the selected item to move up (or down).
    My code works. That is to say it does what I want, only the highlighted item does not correspond to the selected item.
    When I move an item up I would like it to remain selected, which I guess it is as repeated moves will move the item.
    But it does not appear to be working. because the highlight is above the selected item when moving up and below the selected item when moving down.
    Here is my code:
    public class MyClass  implements MouseListener,KeyListener
    private JList linkbox;
    private DefaultListModel dlm;
    public List<String> Links= new ArrayList<String>();
    private String Path;
    private JScrollPane Panel;
        public MyClass  (String path,JScrollPane panel){
        super();
            Path=path;
            Panel=panel;
    //Populate the ArrayList "Links" etcetera.
         dlm = new DefaultListModel();
            linkbox = new JList(dlm);
            for(int k=0;k<Links.size();k++){
                dlm.addElement(Links.get(k));
        public void keyPressed(KeyEvent e) {
        System.out.println("You pressed "+e.getKeyCode());
           if(e.getKeyCode()==38&&e.getModifiers()==KeyEvent.CTRL_MASK){
            Link sellink =linkbox.getSelectedValue();
                MoveUP(sellink);
            if(e.getKeyCode()==40&&e.getModifiers()==KeyEvent.CTRL_MASK){
                Link sellink =get(linkbox.getSelectedValue();
                MoveDown(sellink);
    private void MoveUP(Link link){
        int pos=-1;
        for(int p=0;p<Links.size();p++){
            Link l=Links.get(p);
            if(l.indexOf(link)==0){
            pos=p;
            break;
        if(pos!=-1&&pos>0){
            Links.remove(link);
            Links.add(pos-1,link);
            dlm.removeAllElements();
            for(int k=0;k<Links.size();k++){
            dlm.addElement(Links.get(k));
            Panel.setViewportView(linkbox);
            linkbox.setSelectedIndex(pos-1);
        private void MoveDown(Link link){
            int pos=-1;
            for(int p=0;p<Links.size();p++){
                Link l=Links.get(p);
                if(l.indexOf(link)==0){
                pos=p;
                break;
            if(pos!=Links.size()-1&&pos>0){
            System.out.println("pos= "+pos);
                Links.remove(link);
                Links.add(pos+1,link);
                dlm.removeAllElements();
                for(int k=0;k<Links.size();k++){
                dlm.addElement(Links.get(k));
                Panel.setViewportView(linkbox);
                linkbox.setSelectedIndex(pos+1);
        }And here is a compileable version...
    import java.awt.event.KeyEvent;
    import java.awt.event.KeyListener;
    import java.util.ArrayList;
    import java.util.List;
    import javax.swing.DefaultListModel;
    import javax.swing.JFrame;
    import javax.swing.JList;
    import javax.swing.JScrollPane;
    import javax.swing.UIManager;
    class MoveableItems  implements KeyListener
         private JList jlist;
         private List<String> items = new ArrayList<String>();
         private DefaultListModel dlm;
         private JScrollPane sp;
         public MoveableItems(){
             JFrame f = new JFrame();
           items.add("Fox");
           items.add("Hounds");
           items.add("Cart");
           items.add("Horse");
           items.add("Chicken");
           items.add("Egg");
             dlm = new DefaultListModel();
            jlist = new JList(dlm);
             KeyListener[] kls=jlist.getKeyListeners();
             for(int k=0;k<kls.length;k++){
                 jlist.removeKeyListener(kls[k]); 
             jlist.addKeyListener(this);
             for(int k=0;k<items.size();k++){
                dlm.addElement(items.get(k));
              sp = new JScrollPane();
                sp.setViewportView(jlist);
             f.getContentPane().add(sp);
             f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
             f.setSize(650, 250);
             f.setVisible(true);
         public static void main(String[] args)
             try{
                UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
                }catch(Exception e){System.out.println(e.getMessage());}
             new     MoveableItems();
        public void keyPressed(KeyEvent e) {
        System.out.println("You pressed "+e.getKeyCode());
            if(e.getKeyCode()==38&&e.getModifiers()==KeyEvent.CTRL_MASK){
            String selString =(String)jlist.getSelectedValue();
                MoveUP(selString);
            if(e.getKeyCode()==40&&e.getModifiers()==KeyEvent.CTRL_MASK){
                String selString =(String)jlist.getSelectedValue();
                MoveDown(selString);
        public void keyReleased(KeyEvent e) {
         public void keyTyped(KeyEvent e) {
    private void MoveUP(String link){
        int pos=-1;
        for(int p=0;p<items.size();p++){
            String l=items.get(p);
            if(l.indexOf(link)==0){
            pos=p;
            break;
        if(pos!=-1&&pos>0){
            items.remove(link);
            items.add(pos-1,link);
            dlm.removeAllElements();
            for(int k=0;k<items.size();k++){
            dlm.addElement(items.get(k));
            sp.setViewportView(jlist);
            jlist.setSelectedIndex(pos-1);
            jlist.requestFocus();
        private void MoveDown(String link){
            int pos=-1;
            for(int p=0;p<items.size();p++){
                String l=items.get(p);
                if(l.indexOf(link)==0){
                pos=p;
                break;
            if(pos<items.size()){
            System.out.println("pos= "+pos);
                items.remove(link);
                items.add(pos+1,link);
                dlm.removeAllElements();
                for(int k=0;k<items.size();k++){
                dlm.addElement(items.get(k));
                sp.setViewportView(jlist);
                jlist.setSelectedIndex(pos+1);
                jlist.requestFocus();
    }Now for some reason this works better.
    I notice that the highlight does follow the selection but there is also something else there.
    Still in my original version the highlight seems to appear where the dotted lines are?
    There seems to be dotted lines around the item above or below the selected item (depending on whether you are going up or down).
    Any thoughts at this point would be appreciated.
    -Reg.
    Can anyone explain to me why this is so and if it can be fixed?
    If any one can help I would be grateful,
    -Reg

    You seem to be making a genuine effort. Key Bindings like anything else involves getting familiar with the code and the idiosyncrasies involved and just playing with the code yourself. To get you started, if the JList were called myList I'd do something like this for the up key:
            KeyStroke ctrlUp = KeyStroke.getKeyStroke(KeyEvent.VK_UP, InputEvent.CTRL_DOWN_MASK);
            myList.getInputMap().put(ctrlUp, "Control Up");
            myList.getActionMap().put("Control Up", new AbstractAction()
                public void actionPerformed(ActionEvent e)
                    // do stuff to move your item up
            });Please read the tutorial for details, explanation, etc...

  • How do I create a message box for a listbox, with a 'move item up' and a 'move item down' button?

    In my listbox I want to create an error message for when I click the 'move item up' button and the item is already at the top of the list, but I am not sure how to do it.
    Here is the code I have right now:
    if (ListBox. )
    MessageBox.Show("Item is already at the top of list.");
    return;
    I also want to know how I would do the same for a 'move item down' button (if it is at the bottom of the list and I click 'move item down' button).
    Thanks.

    Here is the code,
    C#
    public void button1_click(object sender, EventArgs e)
    if (ListBox1.SelectedIndex == 0) {
    //MSGBOX
    return;
    //'Your move up code
    public void button2_click(object sender, EventArgs e)
    if (ListBox1.SelectedIndex == ListBox1.Items.Count - 1) {
    //MSGBOX
    return;
    //'Your move down code
    Insert each code in their own buttons.
    VB.net
    Public Sub button1_click(sender As Object, e As EventArgs) Handles UpButton.click
    If ListBox1.SelectedIndex = 0 Then
    'MSGBOX
    Exit Sub
    End If
    ''Your move up code
    End Sub
    Public Sub button2_click(sender As Object, e As EventArgs) Handles DownButton.click
    If ListBox1.SelectedIndex = ListBox1.Items.Count - 1 Then
    'MSGBOX
    Exit Sub
    End If
    ''Your move down code
    End Sub

  • How to move rows up and down on a SharePoint List Item

    Hello,
    I have created a simple Project Plan Template for my team using a SharePoint list.
    I have listed a sample below:
         Date  
                                Tasks        
                                               Owner
    03/09/14                             Gather requirement                        
        X
    05/09/14                             Develop                          
                          Y
    07/09/14                             Deploy                          
                            Y
    Currently there is no functionality in the template to add another task to update the Plan. eg: I want to add another task with a due date 04/09/14 to confirm requirements.
    So basically I want to be able to add an item (task) towards the end and then move it to desired position depending on the due date.
    Please suggest how this can be implemented without complex code changes as I am new to working with SharePoint.
    Many Thanks in advance,
    BH

    Hi ,
    Thanks for the response.
    But I am looking to move the rows in a particular list A and not between 2 separate list items A and B according to the date.
    List Project A has separate tasks defined which needs to accomplished in a timely manner for the project to complete on schedule.
    I want to be able to move these tasks which are in a table on the SharePoint List.
    Hope this is clear.
    Please let me know if you have suggestions for this.
    -BH

  • I'm having a minor problem with "screen drift" - the page moves slightly up and down when moving my mouse around the screen, and continues to do so after stoppi

    I've installed the latest version of Shockwave, updated the driver from Logitech for my mouse (Logitech M525), tried both full screen and regular modes, restarted Firefox repeatedly. This drift is very annoying - I spend the majority of my time on FB - seems like the amount of drift varies from not at all to "damn it, I can't even place my mouse on an object without the screen moving".
    I'm on Windows 7 with an Acer V5-671 laptop - help please!

    You can check for problems with current Flash plugin versions and try these:
    *disable a possible RealPlayer Browser Record Plugin extension for Firefox and update the RealPlayer if installed
    *disable protected mode in the Flash plugin (Flash 11.3+ on Windows Vista and later)
    *disable hardware acceleration in the Flash plugin
    *http://kb.mozillazine.org/Flash#Troubleshooting
    Start Firefox in <u>[[Safe Mode|Safe Mode]]</u> to check if one of the extensions (Firefox/Firefox/Tools > Add-ons > Extensions) or if hardware acceleration is causing the problem (switch to the DEFAULT theme: Firefox/Firefox/Tools > Add-ons > Appearance).
    *Do NOT click the Reset button on the Safe Mode start window or otherwise make changes.
    *https://support.mozilla.org/kb/Safe+Mode
    *https://support.mozilla.org/kb/Troubleshooting+extensions+and+themes

  • 8310 ball will only move left up and down

    My wife was using the phone scrolling through a forum and when she needed to scroll to the right she found she couldn't.  this is the case with all options on the phone.  a battery pull doesn't help and she is on o2 Dudley

    Hello dudleyw, 
    Sorry to hear about your issue.
    Have a look at the following knowledge base article which may help you with your trackball issue. 
    KB29640
    Trackpad, trackball, or keyboard not working on a BlackBerry Smartphone.
    Hope this helps. Have a good day. 
    -SR
    Come follow your BlackBerry Technical Team on twitter! @BlackBerryHelp
    Be sure to click Kudos! for those who have helped you.Click Solution? for posts that have solved your issue(s)!

  • Trackpad is presenting a bug to open and close windows, mission control, and to move/roll the application (App) up and down.

    Totally out of the blue, my trackpad is presenting a "bug". Every time that I try to open and close my mission control, or in the moments that I move / roll up and downs the Applications Screen, my Mac freezes for less than a second.
    It never suffered any damage (NEVER!)! I am feeling very frustrated because I have no idea about what could cause such problem.
    My MacBook Air is running OS X 10.9.5.
    Any help will be very welcome!

    Well, it all really depends on the custom program and how it was written. Does it have an ActiveX interface? If it does, than that's the easiest way to go. If you put an automation refnum on the fron panel, you can right click and it and choose Select ActiveX Class>Browse. The browser will list all of the ActiveX type libraries that are registered on your system. If you can find one that refers to your custom program, then you should be able to use it's methods and properties to control. If it does not have an ActiveX interface, then things get much more difficult.

  • Trying to get a movie clip to go both up and down depending on which button gets clicked

    hello,
    I have a file with 5 movie clips in it. I have a button that when clicks, plays each one. One of the movie clips needs to move both up and down and I am having a lot of trouble with this.
    stop();
    function showVenue(Event:MouseEvent):void
              mc_speaker.play();
    function showSpeaker(Event:MouseEvent):void
              mc_compliance.play();
    function showCompliance(Event:MouseEvent):void
              mc_strategic.play();
              mc_data.play();
    function showStrategic(Event:MouseEvent):void
              mc_data.gotoAndPlay("down");
    function showData(Event:MouseEvent):void
              mc_data.gotoAndPlay("up");
    btn_viewMore_Venue.addEventListener(MouseEvent.CLICK, showVenue);
    btn_viewMore_Speaker.addEventListener(MouseEvent.CLICK, showSpeaker);
    btn_viewMore_Complinace.addEventListener(MouseEvent.CLICK, showCompliance);
    btn_viewMore_Strategic.addEventListener(MouseEvent.CLICK, showStrategic);
    btn_viewMore_Data.addEventListener(MouseEvent.CLICK, showData);
    Is there anyway to attach my file here for someone to look at???
    thanks!
    babs

    Well, on the mc_data movie clip, I had the animation going up and down with stop actions to stop it. so I put labels on those areas and tried to just control it that way. Seemed simple enough, but not working.
    I really don't know how to control the toggle up and down in AS without using the timeline....just trying to help a friend, and ready to scream..I thought this would be so simple...
    would be easier to explain if I could show you a dummy file...but I still don't see an attach button????

  • HT4930 My mouse suddenly started lagging when moving up and down. Left and Right seem to move fine. Waht's wrong?

    My mouse has suddenly started lagging when moving up and down. Left and right movement seems fine. in fact, it's perfect. I tried changing the tracking speed to no avail. it sped up the left and right movement, but "up and down" still remain sketchy. HELP!!

    Hi Torrence,
    You may have to suffer until you can get to your local artist's products store.   There you should be able to buy square metres of fine matt black felt (maybe in a shop selling materials too).   This makes an excellent and inexpensive base that looks good too.   Have used it for years.
    Lay it on your desk and hold it in position with some double sided sticky tape.

  • How can I move items from my Nano to my computer?

    I hate the new iTunes. It used to show what my iPod Nano Gen 6 had in the library and I could easily move items in and out, but now all I can do is add items to the iPod, but not remove.

    See this older post from another forum member Zevoneer covering the different methods and software available to assist you with the task of copying content from your iPod back to your PC and into iTunes.
    https://discussions.apple.com/thread/2452022?start=0&tstart=0
    B-rock

  • Algorithm arranging the Sequence of Records... UP and DOWN arrow

    Is there some kind of algorithm for sequence of existing records with up and down arrows?
    Move a record up (up arrow)
    Move a record down (down arrow)
    I think i need a scrollable resultset (update query) position = ++; etc somthing like that, can someone post a algorithm or sample code (scriplet)
    Thank you in advance

    I have a database field named secuence
    Somthing is wrong with this code 10 dukes thank you in advance:
    <%
    Statement stmt3 = con.createStatement();
    String iSeq =request.getParameter("seq");
    String iID =request.getParameter("ID");
    String action=request.getParameter("action");
    if (request.getParameter("action") != null && action.equals("moveup")) {
              String sql = "update hog_evenementen " +
                        "set sequence = "+ iSeq +" - 1 where id = "+ iID +"; " +
                        "update hog_evenementen " +
                        "set sequence = (sequence + 1) where (sequence = "+ iSeq +" - 1) AND (id <> "+ iID +")";
              stmt3.executeUpdate(sql);
    } else if (request.getParameter("action") != null && action.equals("movedown")) {
              String sql = "update hog_evenementen " +
                        "set sequence = "+ iSeq +" + 1 where id = "+ iID +"; " +
                        "update tblTest " +
                        "set sequence = (sequence - 1) where (sequence = "+ iSeq +" + 1) AND (id <> "+ iID +")";
              stmt3.executeUpdate(sql);
    %>
    Links that move records up and down:
    <a href="evenement.jsp?action=moveup&id=<%=id%>&seq=<%=sequence%>"><img src="images/hog_omhoog_icon.gif" alt="Omhoog" width="12" height="14" border="0"></a></div></td>
    <a href="evenement.jsp?action=moveup&id=<%=id%>&seq=<%=sequence%>"><img src="images/hog_omlaag_icon.gif" alt="Omlaag" width="12" height="14" border="0"></a></div></td>

  • Unable to move preview mode screen up and down on a mac

    I'm teaming with a coworker to build a website on Muse.  He's operating on a PC and I'm operating on a mac.  We are both able to open the muse file and make changes, but I'm experiencing problems when I click over to Preview Mode on my mac.  No matter which mouse I use with my computer (magic trackpad, trackpad on my laptop or regular usb mouse with a wheel) I am unable to move the screen up and down to see the content we built lower on the page.  The pc does not have this same problem.  Ideas?

    Hi ,
    Thanks for the response.
    But I am looking to move the rows in a particular list A and not between 2 separate list items A and B according to the date.
    List Project A has separate tasks defined which needs to accomplished in a timely manner for the project to complete on schedule.
    I want to be able to move these tasks which are in a table on the SharePoint List.
    Hope this is clear.
    Please let me know if you have suggestions for this.
    -BH

  • HT204088 I was billed for a rented movie that never completely down loaded and I never was able to view. How do I get reimbursed???

    I was billed for a rented movie that never completely down loaded and I never was able to view. How do I get reimbursed???

    I'd report the problem to the iTunes Store. 
    Log in to the Store. Click on "Account" in your Quick Links. When you're in your Account information screen, go down to Purchase History and click "See all".
    Find the item that is not downloading properly. If you can't see "Report a Problem" next to the item, click the "Report a problem" button. Now click the "Report a Problem" link next to the item.

  • Hi there. I have a problem with sound on my 4s. When you move the volume slider up, it sounds well. But when I move the volume slider down I will hear barely and unclear sound in my headphone.I tried different headphones but result is same as old one.Help

    Hi there. I have a problem with sound on my 4s. When you move the volume slider up, it sounds well. But when I move the volume slider down I will hear barely and unclear sound in my headphone.I tried different headphones but result is same as old one.Help

    Try A and B
    (A) Restart iPad
    1. Hold down the Sleep/Wake button until the red slider appears.
    2. Drag the slider to turn off iPad.
    3. Turn iPad back on, hold down the Sleep/Wake until the Apple logo appears
    (B) Reset iPad
    Hold down the Sleep/Wake button and the Home button at the same time for at least ten seconds, until the Apple logo appears
    Note: Data will not be affected.

  • Is there a way to make the scroll wheel move up and down instantly like you could with previous versions, instead of moving slowly up and down?

    I've only recently updated my firefox to v 15.0.1 after using v 10 for so long, and I was wondering if there is a way to make the scroll wheel move up and down instantly without having it slowly crawl to it's spot?

    you can disable smooth scrolling.
    *Tools > Options > Advanced > General: Browsing: "Use smooth scrolling"

Maybe you are looking for

  • Win 8.1 converting to look like 7 ? why?

    I bought a laptop with win 8.1 on it, got used to the new operating system, and love it, but now microsoft has put out a critical update in wich make it look like win 7 by adding a minimize and close option on all windows.  Im losing interest in 8.1

  • New Computer - Download TV Shows Paid

    I just got a new computer and when I log into my iTunes account my purchases are not all downloaded. None of my tv shows have appeared. They show up in the category and have an exclamation mark next to them for me to find the file. How do I download

  • Firefox/Mozilla won't run as normal user [SOLVED]

    I have had this weird thing happen, where Mozilla and Firefox wont' work as a normal users.  I fixed this temporarily by allowing non-group rwx access to /tmp, however somehow the problem has returned again.  Has anyone else had this?  I'm not sure w

  • Linking two database  based on DB link

    i have a table emp in ORCL database I have a table dept in ABCD database Please help me how to create a db link and i have to create a new table in ORCL database with the following columns Ename, Deptname taking data from both the databases.

  • Sending a private message on a public Queue

    Hi, I would like to know if it is possible to send a message on a public Queue, after explicitly indicating who is able to extract it, so that any other client (malicious or not) would not be able to read it. Thank's