-
May 20th, 2016, 12:59 PM
#1
Thread Starter
Hyperactive Member
[RESOLVED] Sorting a table column OF dropdowns
I've looked at numerous plugins and have yet to find one that will sort a column of dropdowns (based on selected="selected")
Each dropdown is built like so:
HTML Code:
<select id="Select17">
<option value="P">Pending</option>
<option value="A">Active</option>
<option value="I" selected="selected">Inactive</option>
</select>
Can anyone suggest a jquery plugin that will work for me?
Thanks,
MzPippz
-
May 25th, 2016, 08:56 AM
#2
Re: Sorting a table column OF dropdowns
I don't understand what you mean by:
(based on selected="selected")
Could you elaborate?
-
May 25th, 2016, 09:11 AM
#3
Re: Sorting a table column OF dropdowns
Using various APPEND methods in jQuery you can move the SELECTED option to the top of the HTML list.
Is that what you are trying to do? No need for a plugin.
-
May 25th, 2016, 09:42 AM
#4
Thread Starter
Hyperactive Member
Re: Sorting a table column OF dropdowns
Hey guys,
The issue I was having was trying to lock down a plugin that would get the selected values of the dropdown for each item in the column and sort alphabetically.
Most failed. However, since yesterday, I have been testing a plugin that uses a data-attribute option for sorting. Depending on the plugin, a data-attribute is usually placed on the <td>s or the <select>s of the sortable column.
This, however, isn't always a working solution when you change the values of the dropdowns and then sort again, as I have been doing. Some browsers, like Firefox, are fickle with respect to how they treat cached data attributes and element manipulation. I wrote some js to programmatically change the data-attributes(CACHED, it's not enough to change the DOM values!) upon a change in the selected index of a dropdown, but this was buggy too often for my taste, due to either a weak plugin or an eccentric browser.
Without opening up a whole other can of worms, the most reliable way[still not 100% reliable] to achieve what I want is to use the data-attribute method for sorting a column of dropdowns. Although caution and extra testing is needed because of the unreliable nature of browser behaviour.
Or you could just do away with having to sort a column of dropdowns and redesign the page as I have done.
Thanks,
MzPippz
-
May 25th, 2016, 10:07 AM
#5
Re: [RESOLVED] Sorting a table column OF dropdowns
I load most of my HTML for a page after the page initially loads.
Do this all with AJAX calls and jQuery DOM manipulation.
I load some <SELECT> elements with NO OPTIONS at first and then as you change from record to record in the maintenance you are doing the OPTIONS are set based on the type of record.
All of this works without CACHE issues.
Maybe you should see about loading OPTIONS after the PAGE initially loads as a way to clear yourself of the cache issues.
Without those it's very easy to juggle OPTIONS with JavaScript.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|