Extending dojox.grid.DataGrid - How To Set Formatter?

View: New views
2 Messages — Rating Filter:   Alert me  

Extending dojox.grid.DataGrid - How To Set Formatter?

by OakBehringer :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Basically when I do this:

dojo.declare('My.grid.MaintRenewGrid', dojox.grid.DataGrid, {
       
        store: new dojo.data.ItemFileReadStore({url: 'get-maint-renewals.php'}),
        rowSelector: '20px',
        structure: [
                { field: "serial_number", width: "230px", name: "Serial Number" },
                { field: "expdate", width: "90px", name: "Maintenance Expiration Date", formatter: this.formatExpdate },
                { field: "up_cost", width: "75px", name: "Renewal Cost", formatter: My.grid.MaintRenewGrid.formatPrice },
        ],
        formatPrice: function (val) { return (val == '' ? 'Invalid' : '$' + val); },
        formatExpdate: function (val) { return (val.length ? val : 'n/a'); },
        canSort: function() { return false; }
});

The formatter does not work for either column attempting to do it (using "this" or the fully qualified class name). Any suggestions?

Thanks,
Adam

Re: Extending dojox.grid.DataGrid - How To Set Formatter?

by ozzyaaorn :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Did you fix this? I had the same problem and fixed it thusly :


{... formatter: function () { return this.grid.formatExpdate(arguments); }}

hope that helps...

Context of this in the view is the cell you're operating on ...