0

I am creating application that contains a DataGrid which has 4 columns (name, hours, rate, total).

What I want is to update the total cell whenever the hours or rate values changes.

you may say:

object.setTotal(object.getHours() * object.getRate());

...but I want to know how to update the cell value itself without redrawing the row or the DataGrid. Is this possible?

I got the answer: I used DOM to access the control and update the value. of course I named each control in the DataGrid, for example First row (id=name0, id=hours0, rate0, total0) and so on.

InputElement ele = DOM.getElementById( "total" + context.getIndex()).cast(); ele.setValue(object.getTotal());

Moe
  • 197
  • 6

2 Answers2

3

Cells, individually, cannot be refreshed. But row refresh is possible. So, whenever hours/rate value changes you trigger the row refresh API.

dataGrid.redrawRow( rowIndex );

Above code refreshes the entire row identified by the index 'rowIndex'

Adarsha
  • 895
  • 4
  • 7
0

It is not possible without redaraw, refresh or setData

Abhijith Nagaraja
  • 3,370
  • 6
  • 27
  • 55
  • I got the answer: I used DOM to access the control and update the value. of course I named each control in the DataGrid, for example First row (id=name0, id=hours0, rate0, total0) and so on. InputElement ele = DOM.getElementById( "total" + context.getIndex()).cast(); ele.setValue(object.getTotal()); – Moe Dec 20 '12 at 14:37
  • @Abhijith and Adarsha. I told you so :). I should have had a bet on this. – appbootup Dec 20 '12 at 16:26
  • 1
    I was about to give the same answer. But there is problem with that approach. I hope you will not face it, if you face it comment back... @SSR Spot on – Abhijith Nagaraja Dec 20 '12 at 17:01