[EXTENSION] EUpdateDialog

This is the topic for EUpdateDialog extension.

If you have questions or found a bug let me know.

Couple of things i want to know about this extension.

  1. In my form i have three text box and i need to make sure this three fields are filled up before open the dialog. I have tried in the below mentioned way to put validation by calling function validateForm , alert message opens out but still dialog appears. Any way to overcome this ?




echo CHtml::link('Add Trip Details', '#', 

 

              array(

                     'class'=>'update-dialog-create',

                     'onclick'=>'js:validateForm();return false;',

 

               )

 

                );



  1. My scenario is that i need to display records in cgridview based on criteria. After record got created via dialog , cgridview does not show the updated value. Please help me on this issues.




$criteria = new CDbCriteria;

		$criteria->select = 'transport_code';

		$criteria->condition='identifier_key=:identifierKey';

		$criteria->params=array(':identifierKey'=>"'".trim($unique_id)."'");

		$criteria->group = 'transport_code';

		$criteria->order = 'trip_id';

			

		$dataProvider=new CActiveDataProvider('TempIntTripDetails', array(

							'criteria'=>$criteria));

			

			

	

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

 	'id'=>'int-driver-form-grid',

	'dataProvider'=>$dataProvider,

	

	'columns' => array(

	

		'transport_code',


    array(

      'class' => 'CButtonColumn',

      'deleteButtonUrl' => 'Yii::app()->createUrl("/driverwagescal/internaldriver/TempIntTripDetails/delete",array( "id" => $data->trip_id) )',

      'updateButtonUrl' => 'Yii::app()->createUrl("/driverwagescal/internaldriver/TempIntTripDetails/update",array( "id" => $data->trip_id) )',

      'buttons' => array(

        'delete' => array(

    	//  'deleteConfirmation' => true,

          'click' => 'updateDialogDelete',

    	   

        ),

        'update' => array(

          'click' => 'updateDialogUpdate',

        ),

      ),

    ),

  ),

)); 






Appreciate your help on this issue.

  1. I’m not sure I completely understand the situation, but as far as I get it it’s impossible to do what you want, because there is no form to validate. The form is loaded only after you click the create button, but the empty form will be loaded.

On the other though, a different scenario might be that you want to open some other form with dialog on the page which already have some form. I would probably suggest expanding default create function, or adding your own on binding it to create link as I think it would be easier to maintain, but you can do something similar to this [s]


'onclick' => 'js:$(this).unbind(\'click\');alert(\'bu\');return false;'

[/s] (that’s probably a very bad idea as you won’t have a click event anymore on the link. But I would suggest just writing your own function, you will get much more flexibility.

This code is not tested, but you will probably want to add something like this:


function updateDialogCreateMine( e ){

  e.preventDefault();

  if( validateForm() === true )

    updateDialogActionBase( $( this ).attr( 'href' ), 'Create' );

  else

    alert( 'Fill the form' );

}


jQuery( function($){

  $( 'a.update-dialog-create-mine' ).bind( 'click', updateDialogCreateMine );

});

  1. I made some kind of clone on my app from your provided code and for me it updated. There might be something wrong with a criteria itself or with a cgridview (as I was testing my custom gridview, I run into problems, which I later tested on cgridview, and it doesn’t always work as it is supposed when using pager filter and so on together). Also don’t forget to change line 54 in EUpdateDialog.js if you are using different class or tag name for gridview.

It seems problem is in criteria . Things are working correctly if i did not use the criteria so that means no issue with the class or tag name. Can you pass me the sample code using with criteria for reference ? Appreciate your help .

I just made simple select with simple condition, to make sure it updates, won’t be of any help. I would suggest to turn on the logs, and just get on with the debugging to try and find the problem.

Thanks for your help. I am trying to sort out this issue. I will update the post once i find the solution.

Maybe check your $unique_id it might be something different than you expect. Another "solution" if you are using autoincrementing id would be to order your query by this id in descending order. Just an idea, it might need more polishing.

Good luck solving this issue.

Hi,

I am using random generated unique id to keep track of the records which i got created in dialog page. After record got created via dialog , i found that cgridview got updated in ajax mode by calling url like "


/index.php/driverwagescal/internaldriver/DriverWagesRecords/create?ajax=int-driver-form-grid

. Since i am generating the unique id on each page request, everytime i am getting different unique id. How to overcome this issue ? Any idea ?

Thanks in advance.

Hi,

How about returning generated unique id after creating a record, and sending it with gridview (through hidden field or something like that)?

Hi,

If I put widget CTabView into view - it display first tab correctly but switching is not working.


$this->widget('CTabView',array('tabs'=>array(

	'tab1'=>array('title'=>'Search'), 

	'tab2'=>array('title'=>'Advanced Search')

)));

Any idea?

Hi,

Sorry I can’t help with that, as I haven’t used CTabView anywhere so I actually don’t even know how they work.

I would suggest debuging using Firebug console and see there it goes, as most problems working with AJAX happens because of JS errors, wrong url or parameter.

Best of luck with trying to find the solution.

I need a hint,

After opening dialog window with multiple widgets, content are "drawed" (especially EJuiComboBox). Is there any possible to first load content (not the window), and then show?

Regards!

(sorry for my english)

The widget simply don’t emit any errors (also in firebug). I’ll write if I find something.

If I understand correctly you want to display dialog only after all the contents of this dialog is loaded?

That way you could add an ajax loader or ‘Loading’ text to the content and replace it after all the content finished loading. Or move the opening of the dialog in ajax call.

I’m aware that loading additional widgets, gets the ‘drawing’ effect, and fixing it is my todo list, but as I’m currently busy with other stuff, I won’t be looking into that for at least another week or so.

It’s a great extension! Thanks.

I’m working on an application with a single controller but multiple models. The view provides link to add/update different models. I tried it with one model. It works great! I’ve a question - Upon “close” of the dialog, I’d like to call another controller action to refresh partial changes as a result of the dialog. Please help me out with the java script code here.

I won’t be able to help you with JavaScript as I’m not very good with it (never find time to take a good book and learn it, so I learn it as I go), however if I had to do something like this, I would probably be looking into expanding Ajax success call, by returning additional content and replacing existing with it, or by making another Ajax call to return new content and replacing old content with it, depending on which one would be more appropriate.

I started using EUpdateDialog but I found that the CREATE dialog does not show the datepicker jquery component in the date fields. The original CRUD was created using GIIX. How can I use the EUpdateDialog ext maintaining the original behavior (date field using datepicker)?

The pre-existent view code has a GxActiveForm as follows:

<?php $form = $this->beginWidget(‘GxActiveForm’, array(

'id' =&gt; 'postal-form',


'enableAjaxValidation' =&gt; false,

));

?>

&lt;p class=&quot;note&quot;&gt;


	&lt;?php echo Yii::t('app', 'Fields with'); ?&gt; &lt;span class=&quot;required&quot;&gt;*&lt;/span&gt; &lt;?php echo Yii::t('app', 'are required'); ?&gt;.


&lt;/p&gt;


&lt;?php echo &#036;form-&gt;errorSummary(&#036;model); ?&gt;


	&lt;div class=&quot;row&quot;&gt;


	&lt;?php echo &#036;form-&gt;labelEx(&#036;model,'cod_postal'); ?&gt;


	&lt;?php echo &#036;form-&gt;textField(&#036;model, 'cod_postal'); ?&gt;


	&lt;?php echo &#036;form-&gt;error(&#036;model,'cod_postal'); ?&gt;


	&lt;/div&gt;&#60;&#33;-- row --&#62;


	&lt;div class=&quot;row&quot;&gt;


	&lt;?php echo &#036;form-&gt;labelEx(&#036;model,'localidad'); ?&gt;


	&lt;?php echo &#036;form-&gt;textField(&#036;model, 'localidad', array('maxlength' =&gt; 64)); ?&gt;


	&lt;?php echo &#036;form-&gt;error(&#036;model,'localidad'); ?&gt;


	&lt;/div&gt;&#60;&#33;-- row --&#62;


	&lt;div class=&quot;row&quot;&gt;


	&lt;?php echo &#036;form-&gt;labelEx(&#036;model,'date'); ?&gt;


	&lt;?php &#036;form-&gt;widget('zii.widgets.jui.CJuiDatePicker', array(


		'model' =&gt; &#036;model,


		'name'=&gt;'Postal[bb]',


		'value'=&gt;Yii::app()-&gt;lc-&gt;toLocal(&#036;model-&gt;bb, 'date', 'small'),


		'options' =&gt; array('changeYear' =&gt; true,'dateFormat'=&gt;Yii::app()-&gt;locale-&gt;getDateFormat('calendar_small')),


		));

; ?>

	&lt;?php echo &#036;form-&gt;error(&#036;model,'bb'); ?&gt;


	&lt;/div&gt;&#60;&#33;-- row --&#62;

Thanks for letting me know. I use custom clientScript component so it works for me, but with default Yii clientScript component it doesn’t work. The problem is that for some reason it doesn’t run the jquery-ui widget initialization after retrieving contents. I will be making an update to the extension in a week or so, I will have to look for a solution for this problem.

Oh, I see… Many thanks, you made a very nice work, you are a great contributor to this comunity, I’m personally grateful =) I’ll wait for your update in order to move forwar with my development.

BTW, I have a little suggestion. The first time I click a “add new model” link the dialog opens with no content, a moment later the dialog is filled with the content (retrieved with AJAX).There is a little delay of around two seconds to draw the dialog content. That’s OK, but the end user is in doubt for a couple of seconds, because there is nothing indicating that the dialog is loading contents. Maybe a simple animated “loading” icon while the ajax-retrieved form content is loaded will be enough to make a little enhance of the end user experience.

I think the problem is with jQuery UI. It’s not the first problem I had with jQuery UI and also other this library widgets aren’t initializing either.

Thanks, it’s great you like it :)

Yes, I noticed that it’s missing a ‘loading’ message|icon, so it’s already on my to-do list. I was thinking about updating it little by little, but decided to finish my first Yii app, and then I’ll start polishing my app I will also make a big update to this extension. So it should be coming in a week or two, as there are still some work to be done, also if making a design won’t make me too depressed like it happened the last time :D