Updating optionsDatasource dynamically based on many to many relation in inline edit table

I have a Master-detail user interface with in-line edit option. The composition table looks like below where users can change Account, Cost Centre etc…

imageScreen Shot 2017-12-29 at 7.07.35 PM

My requirements is, refreshing content of cost centre datasource dynamically based on the Account entity of the row where Cost Centre and Account has many-to-many relationship.