• Register
    • Help

    striker  0 Items
    Currently Supporting
    • Home
    • News
    • Forum
    • Wiki
    • Support
      • Manage Subscriptions
      • FAQ
      • Support For
        • VaultWiki 4.x Series
        • VaultWiki.org Site
    • What's New?
    • Buy Now
    • Manual
    • 
    • Support
    • VaultWiki 4.x Series
    • Bug
    • Sortable tables data-sort-value attribute

    1. Welcome to VaultWiki.org, home of the wiki add-on for vBulletin and XenForo!

      VaultWiki allows your existing forum users to collaborate on creating and managing a site's content pages. VaultWiki is a fully-featured and fully-supported wiki solution for vBulletin and XenForo.

      The VaultWiki Team encourages you to join our community of forum administrators and check out VaultWiki for yourself.

    Issue: Sortable tables data-sort-value attribute

    • Issue Tools
      • View Changes
    1. issueid=5128 July 1, 2017 7:46 AM
      ACL ACL is offline
      Regular Member
      Sortable tables data-sort-value attribute

      From reading a 2014 issue it appears VaultWiki supports sortable tables, but I was wondering if there was some further documentation on this, since I've used sorting functions in a couple of MediaWiki articles.

      I understand adding the class "vw-sort-table" will enable sorting, and the following column sort modes are possible:
      • vw-sort-none (don't sort this column)
      • vw-sort-alpha (alphabetically)
      • vw-sort-ddmm (by date in day/month format)
      • vw-sort-mmdd (by date in month/day format)
      • vw-sort-numeric (numerical order)


      These modes are helpful in some cases.

      Is there also a manual sort mode that is comparable to MediaWiki's "data-sort-value" attribute, and if so how would I apply this in VaultWiki? I've got a table of software licencing tiers with tier names which don't match up alphabetically e.g. Basic > Standard > Advanced. A data-sort-value would also be helpful in another column where I have increasing number values for all rows except the last which is "Unlimited". VaultWiki positions Unlimited first and then orders lowest > highest probably because it is interpreted as 0, so I'd like to manually define a numerical value for just this row, e.g. 999.

      Thanks!
    Issue Details
    Issue Number 5128
    Issue Type Bug
    Project VaultWiki 4.x Series
    Category BB-Code Parsing
    Status Fixed
    Priority 3 - Loss of Functionality
    Affected Version 4.0.18
    Fixed Version 4.0.19
    Milestone (none)
    Software DependencyAny
    License TypePaid
    Users able to reproduce bug 0
    Users unable to reproduce bug 0
    Attachments 0
    Assigned Users (none)
    Tags (none)




    1. July 5, 2017 10:47 AM
      pegasus pegasus is offline
      VaultWiki Team
      The attribute you refer to does not exist, as far as I know, but we can easily add it for you in the next release.
      Reply Reply  
    2. July 5, 2017 11:11 AM
      ACL ACL is offline
      Regular Member
      OK, great! That would be fantastic, thanks.
      Reply Reply  
    3. July 6, 2017 1:33 PM
      pegasus pegasus is offline
      VaultWiki Team
      I've been looking at the code. Please see if the attribute "data-sort-key" works and does what you want.
      Reply Reply  
    4. July 6, 2017 2:10 PM
      ACL ACL is offline
      Regular Member
      Thanks for replying so soon. Is the process for implementing this into a data table the same as classes? Is there a special class that needs to be applied to the header row, like vw-sort-numeric? From my brief testing so far it doesn't seem to be working. Should the following example code sort the table in order of Cat > Crocodile > Dog and in reverse Dog > Crocodile > Cat?
      Code:
      [table]
      |-
      ! Pet
      ! Details
      |-
      | data-sort-key=3 | Dog
      | Should order in third place (or first in reverse)
      |-
      | data-sort-key=1 | Cat
      | Should order in first place (or third in reverse)
      |-
      | data-sort-key=2 | Crocodile
      | Should order in second place
      |-
      [/table]
      As a separate question it seems like either vw-sort-numeric doesn't work for currencies (e.g. with a leading $) or there's a sorting problem when sorting by one column and then resorting by another. With four rows each with a price, $139.95 is being ordered first before $49.95, followed by $69.95 and $99.95.

      EDIT: And now without changing anything in the price column the rows are being ordered with $49.95 first then $139.95, $69.95 and $99.95.
      Reply Reply  
    5. July 6, 2017 3:30 PM
      pegasus pegasus is offline
      VaultWiki Team
      Attributes require quotation marks: e.g. data-sort-key="3"

      For the currency issue, and also an issue where only the front-end digits were used for vw-sort-numeric, edit vault/resources/js/sorttable.js (requires starting from an uncompressed version of the file, which you can download in the Members area). Find:
      Code:
      var aa = a ? parseFloat(a[0].replace(/[^0-9.-]/g, '')) : 0;
      Replace with:
      Code:
      var aa = a ? parseFloat(a.replace(/[^0-9.-]/g, '')) : 0;
      Find:
      Code:
      var bb = b ? parseFloat(b[0].replace(/[^0-9.-]/g, '')) : 0;
      Replace with:
      Code:
      var bb = b ? parseFloat(b.replace(/[^0-9.-]/g, '')) : 0;
      (A similar issue exists for date sorting; fix not posted here)

      Additionally, there is an issue where if the original order of the cells is very mixed up (such as D, A, C, B), they may not be sorted correctly on the first attempt (multiple attempts may eventually succeed). Find:
      Code:
      order.splice(j, 0, this);
      Replace with:
      Code:
      order.splice(j + 1, 0, this);
      After applying these two changes, data-sort-key works as expected for me.
      Reply Reply  
    6. July 6, 2017 4:48 PM
      ACL ACL is offline
      Regular Member
      Thanks pegasus, all does seem to be working with the above javascript changes and quotes around the data-sort-key attribute value!
      Reply Reply  
    + Reply

    Assigned Users
    Loading Please Wait
    Tags
    Loading Please Wait
    • Contact Us
    • License Agreement
    • Privacy
    • Terms
    • Top
    All times are GMT -4. The time now is 5:56 PM.
    This site uses cookies to help personalize content, to tailor your experience, and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Learn more… Accept Remind me later
  • striker
    Powered by vBulletin® Version 4.2.5 Beta 2
    Copyright © 2025 vBulletin Solutions Inc. All rights reserved.
    Search Engine Optimisation provided by DragonByte SEO (Pro) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
    Copyright © 2008 - 2024 VaultWiki Team, Cracked Egg Studios, LLC.