cadudecastroalves
01-23-2008, 07:45 AM
Hello people.
I've been developing an application and I'd like to share a little and simple tip. In my application, I've a grid that shows information about domains (similar to a CPanel or Plesk domain manager). One of these columns is Quota that shows to the user how much space the domains have.
In my application, I defined that each quota value equals 0 is a quota with unlimited space. So, I created a little function using the format method fileSize() to show the quota size.
Here's my contribution. It's simple, but very useful.
displayQuota() method:
function displayQuota(value) {
if(value == 0) {
var quota = 'Unlimited';
} else {
var quota = Ext.util.Format.fileSize(value);
}
return quota;
}
Example usage:
var colModel = new Ext.grid.ColumnModel([
{header: "Account", width: 150, sortable: true},
{header: "Domain", width: 150, sortable: true},
{header: "Quota", width: 80, renderer: displayQuota, sortable: true},
{header: "Status", width: 30, sortable: true}
]);
I've been developing an application and I'd like to share a little and simple tip. In my application, I've a grid that shows information about domains (similar to a CPanel or Plesk domain manager). One of these columns is Quota that shows to the user how much space the domains have.
In my application, I defined that each quota value equals 0 is a quota with unlimited space. So, I created a little function using the format method fileSize() to show the quota size.
Here's my contribution. It's simple, but very useful.
displayQuota() method:
function displayQuota(value) {
if(value == 0) {
var quota = 'Unlimited';
} else {
var quota = Ext.util.Format.fileSize(value);
}
return quota;
}
Example usage:
var colModel = new Ext.grid.ColumnModel([
{header: "Account", width: 150, sortable: true},
{header: "Domain", width: 150, sortable: true},
{header: "Quota", width: 80, renderer: displayQuota, sortable: true},
{header: "Status", width: 30, sortable: true}
]);