Getting component from a Grid header cell

I have set some filters for a Grid via adding TextFields to the header row and now I wanted to set programmatically some values for some of these fields (I still don’t know if that would automatically trigger the Grid to reload its contents filtered accordng to the values in the box but I don’t mind because I’ve already applied them at the DataSource level).

My initial approach was to get the header cell with a HeaderRow.geCell(“columnId”), and after that I planned to do a .getComponent() to that header cell, as all that’s inside it is the stated TextField. But when trying so I get the following exception:

“Cannot fetch Component from a cell with type TEXT”

Trying to solve the mistery, I started a debugging session and discovered that Grid.getComponent() does this check in the first place; that is, if the “cellState.type” is that one from the header row, it throws that exception.

Why this behaviour? And how I could overcome this, if possible?

Well, I’m answering myself, hoping this could useful for other users.

To solve my problem I simply add my TextFields to a HashMap I later access by key and simply set the desired value to it.

As for the second doubt I discovered that the value change is not detected by the Grid, so its contents won’t automatically change accordingly to the value on the TextField, even thought that in in
this thread
someone stated that changing the value of a TextField will “fire a ValueChangeEvent”.

I didn’t bother trying to fire a ValueChangeEvent manually to see if it works because it started to become overcomplicated at the first attemps and my code was already working for my purpose.