vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   Community Lounge (https://vborg.vbsupport.ru/forumdisplay.php?f=13)
-   -   YUI 3 expert needed (https://vborg.vbsupport.ru/showthread.php?t=264337)

Ramsesx 05-28-2011 06:31 PM

YUI 3 expert needed
 
Hi, I tried to set up a sorted DataTable using YUI 3, on YUI 2 there was a way using formatter:YAHOO.widget.DataTable.formatNumber to get numbers sorted right.
But on YUI 3 this doesn?t work or I don?t know how to implement it.

For example, this pre-sorted data:
Code:
Code:

YUI().use("datatable-sort", function(Y) {
    var cols = [
        {key:"Company", label:"Click to Sort Column A", sortable:true},
        {key:"Number", label:"Not Sortable Column B", sortable:true},
        {key:"Contact", label:"Click to Sort Column C", sortable:true}
    ],
    presortedData = [
        {Company:"Acme Company", Number:"8", Contact:"John Jones"},
        {Company:"Company Bee", Number:"100", Contact:"Sally Spencer"},
        {Company:"ABC Company", Number:"124", Contact:"John Miles"},
        {Company:"Company BCF", Number:"80", Contact:"Sally Spader"},
        {Company:"Company Blue", Number:"94", Contact:"Robin Smith"}
    ],
    table = new Y.DataTable.Base({
        columnset: cols,
        recordset: presortedData,
        summary: "Contacts list",
        caption: "This table loads with presorted data"
    }).plug(Y.Plugin.DataTableSort, {
            lastSortedBy: {
                field: "Company",
                dir: "asc"
            }
        })
      .render("#presorted");
});

I would like to have the numbers sorted like:
8
80
94
100
124

I?m not familiar with java code, so please keep it simple. Any help would be great, thank you.

Alfa1 05-28-2011 09:21 PM

Why not use jquery?
http://www.jquery4u.com/plugins/30-a...jquery-tables/

kh99 05-29-2011 03:56 AM

Quote:

Originally Posted by Ramsesx (Post 2201010)
...I’m not familiar with java code, so please keep it simple. Any help would be great, thank you.


You just need to take the quotes out from around the numbers (in the presortedData array initialization), so they'll be numbers instead of strings.

(BTW I'm not a YUI 3 expert, I was just looking at an example when I happened to notice that their numbers weren't inside quotes.)

Ramsesx 05-29-2011 07:30 AM

Quote:

Originally Posted by Alfa1 (Post 2201037)

Looks promising, I'll test it out, thanks.

Quote:

Originally Posted by kh99 (Post 2201141)
You just need to take the quotes out from around the numbers (in the presortedData array initialization), so they'll be numbers instead of strings.

(BTW I'm not a YUI 3 expert, I was just looking at an example when I happened to notice that their numbers weren't inside quotes.)

Haven't expected to be that an easy solution :D Thanks a lot.


All times are GMT. The time now is 07:59 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01624 seconds
  • Memory Usage 1,722KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_code_printable
  • (3)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (4)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete