Wait Dialog Before File Download


I have a CGridview populated through a CArrayDataProvider.

The CArrayDataProvider is filled with Information from a Directory-Listing.

Here’s the view:

$this->widget('zii.widgets.grid.CGridView', array(









                    'value'=> 'CHtml::link($data["filename"],array("files/view", "path"=>$data["path"]))',





        'htmlOptions'=>array('style'=>'cursor: pointer;'), 


When the User clicks on one Row he can download the File.

That’s all working fine.

Sometimes it may take some time until the User can save the file after he clicked the appropriate file.

For that reason I want to display a Dialog Box with a Message like ‘Please wait…’ or something like that.

But I have no idea how I can accomplish that.

If I try to add some Javascript-code inside the CHTML::link I only get errors.

Can anybody have an idea or can point me to the right direction how I can get it to work?

Kind regads


In an old project I had a similar problem. I wanted to display a "wait" dialog each time user clicked something in a menu. That project was run on a very slow server, so even simple routes could take long time. So, all I wanted to achieve was to be able to display some loader and redirect page to destination URL in the same time. I did not had to take care about hiding already open wait-dialog, because when page was finally redirected to destination, it was all gone.

This does not solves exactly your problem, but it could be a good start point for you to search for something better. There is no change, if you redirect to another page or to a file download, the result is the same (if I’m getting you right) – you display wait dialog and then redirect browser to file download link / route, so after seeing wait-dialog for some time user will finally be able to download file.

Both menu and columns in Yii are quite similar and are configured using associative arrays with a similar structure, so you also should not have much problems in changing my menu-click to your column-click.

This example comes from my old project, to the code is not that perfect as I would wrote it now. But, then again, it is just a start point for you.

Since, this solution is quite long and complex, I wrote a Wiki article for it. Take a look here: Implementing menu items with progress (wait) dialog.