Judge Jane Farish said his bail application - opposed by police - was adjourned to next week, rather than flat-out rejected.
She told Mr el Mehdi in the dock: "I'm not prepared to admit you to bail today. Your risk of re-offending while on bail is too high given the material I currently have before me."
The Iraqi-born Mr el Mehdi was left fighting for his life and required emergency surgery after severing major arteries on broken windows that he allegedly smashed during the incident.
He lost "a hell of a lot of blood", according to police officers who attended at the scene at the offices in the old Firestone Factory on Langdons Rd.
Police were called to the office at around 12.30pm on Monday after reports of a man going "bananas" in the reception area.
CYF employees, terrified by the incident, fled through back doors from the building to phone police.
The man calmed down only when eight police officers arrived at the scene.
Officers applied an emergency tourniquet to the man's arm while waiting for St John Ambulance, and he was rushed to Christchurch Hospital for emergency surgery.
Police said he was becoming increasingly "shaky" due to the loss of blood when they spoke to him.
After the incident, blood trails were seen stretching for around 50 metres from where the incident occurred at the office reception.
Pools of blood were congealing several hours after the incident, while independent cleaning contractors were on the scene, picking up broken glass and water-blasting blood from the carpark.
Staff at the makeshift office inside the former Firestone Factory, forced to work there after the Canterbury earthquakes, were upset by the rampage.
The woman allegedly assaulted by the accused was said to be "shaken but unhurt" and was recovering at home.
One worker, who did not wish to be named, said "It was very scary."
Brendan Boyle, chief executive for the Ministry of Social Development, said the alleged attack had been "deeply upsetting and unexpected" for his staff.