Results 1 to 5 of 5

Thread: [RESOLVED] Sorting a table column OF dropdowns

  1. #1

    Thread Starter
    Hyperactive Member Ms.Longstocking's Avatar
    Join Date
    Oct 2006
    Posts
    399

    Resolved [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

  2. #2
    Super Moderator dday9's Avatar
    Join Date
    Mar 2011
    Location
    South Louisiana
    Posts
    11,762

    Re: Sorting a table column OF dropdowns

    I don't understand what you mean by:
    (based on selected="selected")
    Could you elaborate?
    "Code is like humor. When you have to explain it, it is bad." - Cory House
    VbLessons | Code Tags | Sword of Fury - Jameram

  3. #3
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    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.

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

  4. #4

    Thread Starter
    Hyperactive Member Ms.Longstocking's Avatar
    Join Date
    Oct 2006
    Posts
    399

    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

  5. #5
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    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.

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width