user715045
user715045

Reputation: 155

Can I calculate a field directly in an Extjs grid?

Example table:

|-Field quantity-|-Field quantity loss-|----Total------|
|-----2----------|-------4-------------|---total=2+4---|
|-----3----------|-------5-------------|---total=3+5---|

Can I render it by function on extjs?

total=field quantity + Field quantity Loss

Upvotes: 1

Views: 2785

Answers (1)

turbod
turbod

Reputation: 1988

Yes, you must use the grid getColumnModel method.

  grid.getColumnModel().setRenderer(2, function(value, metaData, record, rowIndex, colIndex, store) {
      return record.get('quantity') + record.get('loss');
    });

More info: http://dev.sencha.com/deploy/ext-3.3.1/docs/?class=Ext.grid.GridPanel and
http://dev.sencha.com/deploy/ext-3.3.1/docs/?class=Ext.grid.ColumnModel?class=Ext.grid.ColumnModel

Upvotes: 3

Related Questions