I have two Listboxes (select_tag) containing values and I would to create a button that transfer a value from one to the other.
I would like the user to be able to click on one value or more and move them to the other list.
Only then a submit button will send it to the server.
any idea how should I implement it ?
What component/action should I use ?
any design tip or reference that will help me google further will be welcome.
check this website
http://elegantcode.com/2009/07/01/jquery-playing-with-select-dropdownlistcombobox/
basically using jQuery it's the simplest solution.
get element by it's ID or css
get selected value by selector
get other element
add value to the new list by appending html code to existing
Related
There are lots of similar questions to this on SO but none of them have really provided an answer to my particular case. Or at least I can't figure it out!
I have a form with an autocomplete field which is used to populate other fields if a record exists.
I have found that some users type in a value and click to the next cell using the mouse and therefore do not make a selection from the autocomplete list. It's possible that they have typed a value with a matching record in the input field and in that case I want the form to be populated with the appropriate data. Or if it doesn't, then clear the form.
The only way I can think of to check the value exists in the database is to use the change event to make an ajax call to retrieve the data but that doesn't seem like a very elegant solution and I'd be very surprised if there isn't a better way to do this since it seems to me that this would be a very common scenario...
Is there a way to retain the autocomplete array and check it against the input value in the change event? Or how else can I do it?
What you can do is stash away a copy of the data returned in the ajax call's success callback.
You can then add a blur event handler to the autocomplete input, so it'll be called whenever the user clicks away to the next field. In the event handler, check the stashed ajax data, and if there was only a single possible match, use that to populate the input.
I'm trying to add new field in SugarFields and i have many problems. I have to create a new field which is combination of relate field and multienum, when user clicks to select one/many item(s) the list will be loaded to dropdown list (multiselect). I have copied and modified relate field but i can't see how to get data from pop-up window
Have anyone tried this before? Please give me a clue. I'm using SugarCE-6.5.13
Thank you.
I can't upload image so this is a link from mediafire :(
http://www.mediafire.com/view/523c1kwewld18hn#
You do not need to create a custom field. What you actually want to do is add some custom JavaScript that will make an ajax call to the server to obtain the values for the multi-select from the relate.
There are two different types of data for a relate field. Data when you type ahead and data that is returned from a popup.
For the popup: you will need to override the function set_return(popup_reply_data)
I can't remember off the top of my head, how to handle the type ahead.
I have 2 gsp's say, "a.gsp" and "b.gsp".
"a.gsp" have combobox, from which user can select options.
My question is that, if the user shift to "b.gsp" and then come back to "a.gsp", the combobox selected option should be still there.
How to achieve this ?
You can do multiple things to achieve this. Depending on your requirements you may:
Use javascript and cookies.
Pass the value selected in the combobox into the controller when you naviate to b.gsp and into a hidden field in b.gsp, but then you have to pass it back to the controller once more when you want to see a.gsp.
Pass the selected value inside session/flash scope
From your question it sounds like you are not fully embracing Grails' MVC architecture and using controllers correctly to prepare data and pass structured data through to your view.
To begin with, rename your controller actions and views to something meaningful rather than a,b. Even if just for testing a small sample, as taking shortcuts can lead to long term bad habits...
Secondly, if you are using a tag then you would use the value attribute to indicate what should be selected.
Read about the tag and its attributes here : http://grails.org/doc/2.1.0/ref/Tags/select.html
Give us more details and perhaps we can help.
Thanks for the clarification, so I'm assuming that there could be any number of ways a user might leave the current a.gsp page and come back, but whatever happens you want the browser to remember the selected option. In this case I would use the jQuery cookie library, its very small, won't impact performance as you're doing very litte work and should be very quick for you to setup.. See: https://github.com/carhartl/jquery-cookie
Set a cookie in an onChange handler based on your selects val() value.
When your page loads (document ready), if you get a value when reading the cookie, then try and set the select value.
On Telerik demo site we can see an example of how to implement kind of functionality: "check all checkbox in a grid's column". But in my case it has 2 disadvantages:
It didn't check all checkbox on all pages.
It didn't save a state of checkboxes on different pages.
Is anybody know how to resolve these issues? Thanks in advance.
As long as I know there's no built-in functionality to do so. The same problem happens when you select records on page one and change to page two, you loose whatever you selected before.
To achieve that functionality you have 2 options (I've used both on previous projects)
1) On each check make an Ajax call to one of your controllers and store whatever you selected on a Session Variable (This can be inefficient if you have a lot of records)
2) Create a javascript variable and store your selections there, and send back to the controller using a json variable or a comma separated values string
As I said, I've used both approachs so it depends on if this works for you or not
Hope it helps
I can't test this, so I'm not 100% sure, but looking at Telerik's example, one reason it's not persisted is because every "page" of the grid requires a postback, and in the controller action result method, they aren't passing in the model (or view model) for the items that are bound to the grid, they're only returning that list of items back to the view, so it will never "save" which items are checked/selected and which ones aren't. You should be able to get around this by making your view model a parameter into the HttpPost action result method and then passing that list back to the view after the post so that it retains which items are selected instead of creating a new one. This won't solve the issue with not selecting all the items, but it should at least retain which ones are selected throughout the pages. I think the reason for it not working with all items is it can only select the ones that are actually being displayed at the time. You may want to do a post (or ajax) to select "all" items.
One of the major reasons for using paging in grids is so that you don't have to retrieve all of the data from the data store and generate a lot of HTML to push to the client.
It's been my experience that most users understand that a "select all" check box only checks the items on the current page. I've not seen a site where checking such a check box would actually check all records, even those I can't see.
If you have an action which will affect more than the current page of records, I would suggest that you add a button which clearly indicates that the action will affect all records, then send a command to your data layer which will perform that action. This will perform better (you don't have to send a potentially long list of ids across the wire) and allow users to understand the repercussions of their action.
I have a combobox and that present all the values (1 to many) of my object.
I have implemnted a text field with ajax that retrieves values from the DB using ajax.
Now, want to a add a button that inserts the data from the textfield to the combobox.
I than would like that it would be saved only when user choose to.
I am having troubles implementing the add button that adds the data only on the client side and waits untill the user clicks on save.
Any suggestions?
Rails cast maybe ?
Thanks
http://railscasts.com/episodes/102-auto-complete-association
The railscast above implements what you want with autocomplete feature, watch it fully, you will be good to go, I hope.
Thanks.