Click here to Skip to main content
15,914,608 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi ,

Can anyone suggest me the best way to create a draggable listbox , I am using .net mvc 4 and jquery .I have two listboxes . I want to drag records from 1st listbox to 2nd list box without any page refresh .

Thanks & Regards

What I have tried:

I want to drag records from 1st listbox to 2nd list box without any page refresh .
Posted
Updated 22-Jan-17 20:03pm
Comments
Afzaal Ahmad Zeeshan 21-Jan-17 13:42pm    
Did you try drag and drop API itself? I think that will work quite well.

But know that, it requires some of the class names to be applied to the element (listbox), so do apply them.

1 solution

1. Include the latest version of jQuery library and jQuery UI from google CDN.
2. Include jQuery fieldChooser plugin after jQuery javascript library.

view source:


3.Markup html structure.

view source:
<pre lang="text">

Item 1

Item 2

Item 3

Item 4

Item 5

...



4.The javascript.

view source
JavaScript
<script>
$(document).ready(function () {
var $chooser = $("#fieldChooser").fieldChooser();
var $sourceFields = $("#sourceFields").children();
$chooser.getSourceList().add($sourceFields);
});
</script>

5. Using CSS as per required

CSS
div#sourceFields {
display: none;
}
div#fieldChooser {
width: 350px;
}
.fc-field {
margin: 0 0 0 0;
padding: 5px;
font-size: 1.2em;
width: 120px;
outline: #777777 ridge thin;
background-color: #cccccc;
}
.fc-selected {
background-color: #999999;
}
.fc-field-list {
margin: 0;
padding: 3px 3px 3px 3px;
margin-right: 10px;
outline: #333333 solid thin;
height: 600px;
width: 150px;
overflow: scroll;
}
.fc-source-fields {
float: left;
}
.fc-destination-fields {
float: right;
}
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900