Try this.
data = Map[<|"id" -> #, "T1" -> #, "T2" -> # + 1|> &, Range[40]];
createViewDb[Dynamic@output_, Dynamic@selected_,Dynamic@data_] :=
(selected = Table[True, {i, 1, Length@data}];
DynamicWrapper[
Dataset[Query[All,
KeySort@<|#, "" -> Checkbox[Dynamic@selected[[#id]]]|> &]@
data], output = Query[Select[TrueQ@selected[[#id]] &]]@data]);
Column[{createViewDb[Dynamic@output, Dynamic@selected, Dynamic@data],
Dynamic@selected, Dynamic@Dataset@output}]
Note the annoying behaviour of Dynamic@Dataset@output when displaying the output. This is why I avoided putting Dynamic around Dataset in createViewDb.