YUI().use("datatype-date", "datatable", function (Y) {

    function calculate(o) {
        return "$" + (o.data.price - o.data.cost).toFixed(2);
    }

    var table = new Y.DataTable({
        columns: ["id", "name", { label: "profit", formatter: calculate }],
        data: [
            { id: "ga-3475", name: "gadget", price: 6.99, cost: 4.99 },
            { id: "sp-9980", name: "sprocket", price: 3.75, cost: 2.75 },
            { id: "wi-0650", name: "widget", price: 4.25, cost: 3.25 }
        ],
        caption:"Data formatting with custom function"
    }).render("#function");

});
