Namita,
Expand and collapse is nothing but showing & hiding of the controls under the panel header.
You can sure do so by basic javascripting or by calling setVisible(true) or false on the controls underneath to achieve the same.
Regards,
Rutika Bodas