I finally resolved this problem. I basically created one datatable and hid it, depending on the column clicked I used the backing bean to populate the datatable accordingly. I made the onclick event call a function in the backing bean using the following code:
<p:column headerText="Train" style="font-size:90%;font-family:Times New Roman, Times, serif;">
<p:commandLink onclick="javascript:ShowHide('HiddenDiv');"
id="tableUpdater" update=":closeButton,:subForm:trainTable" value="#{rail.trainNo}"
action="#{yardMaster.populateTrainDetails(rail.trainNo)}"
style="font-family:Times New Roman, Times, serif;">
</p:commandLink>
</p:column>
So basically something like a dynamic datatable.