Dimension Display functionality on a form displaying the grouped records.

I have the records as follows in the Table.
ItemId InventDimId Qty
Item1 10001_1 25
Item1 10001_1 50
Item1 10001_2 75
Item2 10001_1 40
Now in the form I will see the records by grouping as follows.
Item1 10001_1 75
Item1 10001_2 75
Item2 10001_1 40
I will group the records as above by writing the query in init method .
But I have a Dimension Display button(which we see on the standard forms).

Now when I check mark the required dimensions, the dimesions are not being seen on the form after using the code

Can anyone please let me know how to do this ?

So - what happens when you have different dimensions for same item???

am grouping based on the inventdimid , and inventdimid will be different for different comb. of dimensions.

I can achieve this requirement by using a temp. table , but I dont want to use temp table.