Your translation is correct, apart from missing the word viri.
"The whole state was thanking" is indeed translated well with Tota civitas gratias agebat.
The expression gratias agere requires dative to indicate who is thanked.
Therefore if you want to thank "this man's brother" (frater huius viri), the dative expression you need is fratri huius viri.
The genitive huius viri ("this man's") does not change.
The exact translation of "alone" depends on what it refers to.
The most natural interpretation is that it refers to the brother, whence solus takes the gender and case of fratri.
The singular masculine dative is soli — note that solus is declined like unus rather than like bonus.
(The genitive would be solius.)
This leaves us with this translation: Tota civitas fratri huius viri soli gratias agebat.
If you wish "alone" to refer to the man (whose brother is being thanked), switch solus to the same form as huius viri.
The singular masculine genitive is solius.
Thus you get: Tota civitas fratri huius viri solius gratias agebat.
I doubt this was intended, though.
(An earlier version of the question mentioned that soli was genitive. This is why I added some emphasis on its declination.)