I have the coordinates of the cell (row, column indexes) of a grid. How can I retrieve the cell's value?
I don't want to retrieve the whole row, just that one cell with (x,y) coordinates.
I'm using gwt 2.6.1
, gxt 3.x
I have the coordinates of the cell (row, column indexes) of a grid. How can I retrieve the cell's value?
I don't want to retrieve the whole row, just that one cell with (x,y) coordinates.
I'm using gwt 2.6.1
, gxt 3.x
The easiest way is to get the row first, and from that, get the cell. The
Grid<T>
is not a spreadsheet - it is not just a bag of cells, or rows and columns, it is instead a fixed set of columns that describe how to read each row.Finding the row (of type
T
) is pretty easy - using the row index, ask theListStore<T>
for the item with that index.Then, we need the
ColumnConfig<T, ?>
that matches the column you want. This is where things get a bit interesting - what is that?
? Your specific usecase might mean that all columns are the same type, but this is not always the case, so the grid doesn't assume it. Let's say in our case though that we know that column with index 4 holdsString
values - then we can cast anyColumnConfig<T, ?>
toColumnConfig<T, String>
.Now we have the row, and we have the column - the intersection of these is the specific cell you are after. To read out the value of that cell, we take the
ValueProvider
in the column (when you build the column, you provided this as an argument), and use it to read out the value in that column, for the row model.