Override FormDataSource method executeQuery:
public void executeQuery() { SomeTable T = this.cursor(); select * from T where …; }
But be aware that in this case grid will not support sorting and filtering.
Dynamics AX Training