The Gallery is deprecated. No new Gallery components may be submitted, and modifying existing components is disabled. For more information please read the Gallery Deprecation blog post. This is a static snapshot of the Gallery for archive purposes.
Return to DataTable Formatters
YUI({
//Last Gallery Build of this module
gallery: 'gallery-2013.01.09-23-24'
}).use('datatable','gallery-datatable-formatters', function(Y) {
//------------------ B A S I C U S A G E ---------------------
//
// Use "standard" named formatters within a DT ...
//
var dt1 = new Y.DataTable({
data: some_data,
columns: [
{ key:"start_date", label:"Start", formatter:"fullDate" },
{ key:"end_date", label:"End", formatter:"default",
formatOptions:{ type:'date', formatConfig:{ format:'%F' } } },
{ key:"qty", label:"Inventory Qty", formatter:"comma" },
{ key:"cost", label:"Carried Cost", formatter:"currency",
formatConfig:{ prefix:'£', thousandsSeparator:","} }
]
});
//------------------ A D V A N C E D U S A G E ---------------------
//
// Define a custom status code hash ... used on column "estatus"
//
var estatusCodes = {
1: "Furloughed",
2: "Sick Leave",
3: "TDY",
4: "Field Office",
5: "Headquarters"
};
// used in a Column as;
// { key:"estatus", formatter:"custom", formatConfig:estatusCodes }
// Add a "named" formatter to the standard names ...
Y.DataTable.Formatters.formatStrings['sterling'] = {
type:'number',
formatConfig:{ prefix:'£', thousandsSeparator:","}
};
//
// Define columns for a more detailed DataTable, using custom format codes ...
//
var cols = [
// four columns of same key, different Date formatting ...
{ key:"edate", label:"Start Date", formatter:"shortDate" },
{ key:"edate", label:"Start Date", formatter:"longDate" },
{ key:"edate", label:"Start Date", formatter:"fullDate" },
{ key:"edate", label:"Start Date", formatter:"default",
formatOptions:{ type:'date', formatConfig:{ format:'%F' } }
},
{ key:"esalary", label:"esalary 1", formatter:"currency" },
{ key:"esalary", label:"esalary 2", formatter:"general2" },
{ key:"esalary", label:"esalary 3", formatter:"currency",
formatConfig:{ prefix:'£', thousandsSeparator:","} },
{ key:"esalary", label:"esalary 4", formatter:"sterling" },
{ key:"estatus", label:"Emp Status", formatter:"object",
formatOptions:estatusCodes },
{ key:"emarried", label:"Marital Status",
formatter:"hash",
formatConfig:{ s:"Single", m:"Married", d:"Divorced", w:"Widowed", u:"Unknown" }
}
];
//
// Create the DataTable and render it
//
var myDTf = new Y.DataTable({
columns: cols,
data: jsData
}).render("#dtable_formatted");
});
/home/y/libexec/ant/bin/ant all Buildfile: build.xml [echo] Starting Build For gallery-datatable-formatters clean: init: [mkdir] Created dir: /home/y/var/builds/workspace/gallery/build_tmp/src/yui3-gallery/src/gallery-datatable-formatters/build_tmp [echo] Starting Build For gallery-datatable-formatters -lint-server: [echo] Starting Build For gallery-datatable-formatters -node: [echo] For faster builds, install Node.js. -concatdebug: [copy] Copying 1 file to /home/y/var/builds/workspace/gallery/build_tmp/src/yui3-gallery/src/gallery-datatable-formatters/build_tmp/ant [delete] Deleting directory /home/y/var/builds/workspace/gallery/build_tmp/src/yui3-gallery/src/gallery-datatable-formatters/build_tmp/ant -registerdebug: [copy] Copying 1 file to /home/y/var/builds/workspace/gallery/build_tmp/src/yui3-gallery/src/gallery-datatable-formatters/build_tmp -prependdebug: -appenddebug: builddebug: -createcore: [copy] Copying 1 file to /home/y/var/builds/workspace/gallery/build_tmp/src/yui3-gallery/src/gallery-datatable-formatters/build_tmp -loggerregex: buildcore: -rollupjs: -concatskins: -buildskins: -rollupcss: buildskins: -buildlangs: -rolluplangs: buildlangs: build: build-coverage: [echo] Creating coverage file for: /home/y/var/builds/workspace/gallery/build_tmp/src/yui3-gallery/src/gallery-datatable-formatters/build_tmp/gallery-datatable-formatters.js [move] Moving 1 file to /home/y/var/builds/workspace/gallery/build_tmp/src/yui3-gallery/src/gallery-datatable-formatters/build_tmp [move] Moving 1 file to /home/y/var/builds/workspace/gallery/build_tmp/src/yui3-gallery/src/gallery-datatable-formatters/build_tmp minify: [yuicompressor] Compressing /home/y/var/builds/workspace/gallery/build_tmp/src/yui3-gallery/src/gallery-datatable-formatters/build_tmp/gallery-datatable-formatters.js [yuicompressor] [yuicompressor] [WARNING] Try to use a single 'var' statement per scope. [yuicompressor] .bind,YObject=Y.Object; ---> var <--- data=model.toJSON(),clientId= [yuicompressor] [yuicompressor] [WARNING] The symbol isArray is declared but is apparently never used. [yuicompressor] This code can probably be written in a more compact way. [yuicompressor] ){var Lang=Y.Lang, ---> isArray <--- =Lang.isArray,isNumber=Lang.isNumber [yuicompressor] [yuicompressor] [WARNING] The symbol isNumber is declared but is apparently never used. [yuicompressor] This code can probably be written in a more compact way. [yuicompressor] .Lang,isArray=Lang.isArray, ---> isNumber <--- =Lang.isNumber,isString=Lang.isString [yuicompressor] [yuicompressor] [WARNING] The symbol isString is declared but is apparently never used. [yuicompressor] This code can probably be written in a more compact way. [yuicompressor] .isArray,isNumber=Lang.isNumber, ---> isString <--- =Lang.isString,fromTemplate=Lang.sub [yuicompressor] [yuicompressor] [WARNING] The symbol toArray is declared but is apparently never used. [yuicompressor] This code can probably be written in a more compact way. [yuicompressor] ,htmlEscape=Y.Escape.html, ---> toArray <--- =Y.Array,bind=Y.bind [yuicompressor] [yuicompressor] [WARNING] The symbol bind is declared but is apparently never used. [yuicompressor] This code can probably be written in a more compact way. [yuicompressor] .html,toArray=Y.Array, ---> bind <--- =Y.bind,YObject=Y.Object [yuicompressor] [yuicompressor] [WARNING] The symbol YObject is declared but is apparently never used. [yuicompressor] This code can probably be written in a more compact way. [yuicompressor] .Array,bind=Y.bind, ---> YObject <--- =Y.Object;var data=model. [yuicompressor] Compressed to /home/y/var/builds/workspace/gallery/build_tmp/src/yui3-gallery/src/gallery-datatable-formatters/build_tmp/gallery-datatable-formatters-min.js lint: [echo] Using Rhino. Install nodejs to improve jslint speed, or skip with -Dlint.skip=true [java] Running JSLint on : /home/y/var/builds/workspace/gallery/build_tmp/src/yui3-gallery/src/gallery-datatable-formatters/build_tmp/gallery-datatable-formatters.js [java] [java] [java] 18, 4: Mixed spaces and tabs. [java] columns: [ [java] [java] 19, 8: Mixed spaces and tabs. [java] { key:"start_date", label:"Start", formatter:"fullDate" }, [java] [java] 20, 12: Mixed spaces and tabs. [java] { key:"end_date", label:"End", formatter:"default", [java] [java] 22, 4: Mixed spaces and tabs. [java] { key:"qty", label:"Inventory Qty", formatter:"comma" }, [java] [java] 23, 8: Mixed spaces and tabs. [java] { key:"cost", label:"Carried Cost", formatter:"currency", [java] [java] 25, 4: Mixed spaces and tabs. [java] ] [java] [java] 124, 12: Expected '{' and instead saw 'value'. [java] value = Y.DataType.Date.format(o.value,fmtConf); [java] [java] 126, 12: Expected '{' and instead saw 'value'. [java] value = Y.DataType.Number.format(o.value,fmtConf); [java] [java] 193, 25: Expected '{' and instead saw 'value'. [java] value = Y.DataTable.Formatters.namedFormatter.call(host,col.formatter,formatterData); [java] [java] 196, 25: Expected '{' and instead saw 'value'. [java] value = fromTemplate("{" + value + "}", col.formatConfig ); [java] [java] 199, 25: Expected '{' and instead saw 'value'. [java] value = fromTemplate(col.formatter, formatterData); [java] [java] 225, 2: Missing semicolon. [java] } [java] [java] [java] local: deploybuild: [copy] Copying 4 files to /home/y/var/builds/workspace/gallery/build_tmp/src/yui3-gallery/build/gallery-datatable-formatters deployassets: deployskins: deploylang: deploydocs: deploy: all: BUILD SUCCESSFUL Total time: 3 seconds
All code on this site is licensed under the BSD License unless stated otherwise.