Yii Framework Forum: [EXTENSION] Ajax CRUD gii Template - Yii Framework Forum

Jump to content

  • (2 Pages)
  • +
  • 1
  • 2
  • You cannot start a new topic
  • You cannot reply to this topic

[EXTENSION] Ajax CRUD gii Template Rate Topic: -----

#1 User is offline   drumaddict 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 91
  • Joined: 04-October 10
  • Location:Athens,Greece

Posted 05 November 2011 - 05:19 AM

I always thought that the navigation in the view files that the default gii CRUD generator creates is too complex.
This CRUD gii template generates a single Administration page with a CGridView.Update/Create forms and model details view are rendered in a Fancybox Window and deletions go through a confirmation dialog (jUI).The form works with client validation(given that your model validation rules are included in the rules supported by the current Yii client validation).You can switch to Ajax Validation simply by setting the relevant option in CActiveForm instantiation in _ajax_form file,and uncommenting the performAjaxValidation call in ReturnForm action of the controller.See links below

DEMO:SK Yii Test Lab.
Yii Extension Page
0

#2 User is offline   lightglitch 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 33
  • Joined: 05-January 10

Posted 05 November 2011 - 07:04 PM

Looks nice but the popups animations are a little to much for me.
0

#3 User is offline   drumaddict 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 91
  • Joined: 04-October 10
  • Location:Athens,Greece

Posted 05 November 2011 - 07:46 PM

View Postlightglitch, on 05 November 2011 - 07:04 PM, said:

Looks nice but the popups animations are a little to much for me.

No problem,go to the fancybox settings and change the animations....



0

#4 User is offline   jInuQ 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 2
  • Joined: 09-November 11

Posted 11 December 2011 - 06:28 PM

@drumaddict
The new crud template is nice. I ran into a problem with it, that took me a minute to figure out. My SQL tables don't have an id column. I used id"$TableName" (e.g idTest). This breaks the template as it is looking for id(e.g Test.id). A fix I found that works is is to overload the __get() and have it return the correct variable when id is requested. Given my lack of familiarity with Yii is there a way to add a check of the model primaryKey variable?
0

#5 User is offline   drumaddict 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 91
  • Joined: 04-October 10
  • Location:Athens,Greece

Posted 11 December 2011 - 06:52 PM

View PostjInuQ, on 11 December 2011 - 06:28 PM, said:

@drumaddict
The new crud template is nice. I ran into a problem with it, that took me a minute to figure out. My SQL tables don't have an id column. I used id"$TableName" (e.g idTest). This breaks the template as it is looking for id(e.g Test.id). A fix I found that works is is to overload the __get() and have it return the correct variable when id is requested. Given my lack of familiarity with Yii is there a way to add a check of the model primaryKey variable?

You mean modify the template code to suit any primary key name?It could be done,but it's something you'll have to figure out for yourself.I kept things simple because most of times people name the primary key as id.But thanks for reminding me that maybe I have to stress this out in my extension page,-I don't mention this anywhere.Why don't you just rename the primary key as id?
Wishing you success!


0

#6 User is offline   jInuQ 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 2
  • Joined: 09-November 11

Posted 17 December 2011 - 03:46 PM

I didn't rename is because i have 20+ table that are set up that way. Which becomes a pain to redo. Thanks for the work on the crud. 8^)
0

#7 User is offline   PartySoft 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 1
  • Joined: 11-May 12

Posted 11 May 2012 - 06:32 AM

any hope to update this plugin to work with 1.10 ? it gives some js errors, and breaks down the ajax and fancybox functionality
0

#8 User is offline   Sampa 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 173
  • Joined: 18-December 11
  • Location:Stockholm,Sweden

Posted 16 May 2012 - 09:45 AM

View PostPartySoft, on 11 May 2012 - 06:32 AM, said:

any hope to update this plugin to work with 1.10 ? it gives some js errors, and breaks down the ajax and fancybox functionality

I have it working with that yii version... o_O
Try posting the js errors instead.
0

#9 User is offline   wyginwys 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 25
  • Joined: 15-February 12

Posted 29 May 2012 - 10:10 AM

View PostSampa, on 16 May 2012 - 09:45 AM, said:

I have it working with that yii version... o_O
Try posting the js errors instead.



The error I am getting is
"variable $js_afterValidate not defined"
or something like that. I solved it inserting
$js_afterValidate="";
in the _ajax_form.php

Now I am trying to put CJUiDatePicker widget on _ajax_form.php
but it dont work.
0

#10 User is offline   Israel 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 1
  • Joined: 23-February 12

Posted 11 June 2012 - 12:43 PM

Dears,

I'm new for Yii and I started to develop an application using the Ajax CRUD gii Template, but I'm having a problem. I have some custom validations that are made on the server side. That validations query information in the database and return the response to the page in the JSON's format. The problem is that the page is not associating the message to the attribute, but it shows a generic message (the error message setted in the <div id='error-note'...>). The JSON message's format returned to the page seems like this: {"Company_name": ["This name already exists in the database!"]}. How can I fix this and show the correct message?

Best regards!


Israel Boudoux
0

#11 User is offline   iceinrain 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 13
  • Joined: 18-May 12

Posted 02 July 2012 - 07:15 PM

ajax_create and ajax_update doesn't work for me
what could possibly happen?
0

#12 User is offline   iceinrain 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 13
  • Joined: 18-May 12

Posted 03 July 2012 - 08:49 PM

after i ttried to figure it out,,
i found in _ajax_form on line 50
'afterValidate'=>$js_afterValidate,

should be commented,, maybe that variable come from one of your js_plugin,, maybe i should find it again
0

#13 User is offline   iceinrain 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 13
  • Joined: 18-May 12

Posted 05 July 2012 - 09:23 AM

that line should be 'afterValidate'=>'$.js_afterValidate',
just a little dot can mess whole control
0

#14 User is offline   mrsafraz 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 1
  • Joined: 18-July 12

Posted 23 July 2012 - 12:35 AM

View Postdrumaddict, on 05 November 2011 - 05:19 AM, said:

I always thought that the navigation in the view files that the default gii CRUD generator creates is too complex.
This CRUD gii template ..........


I could see in your code that you use
url : "<?php echo Yii::app()->request->baseUrl; ?>/someController/returnView"

Why shouldn't you use
url: "<?php echo $this->createUrl("returnView"); ?>"
instead? (so that the controller name is not hard-coded)
0

#15 User is offline   drumaddict 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 91
  • Joined: 04-October 10
  • Location:Athens,Greece

Posted 23 July 2012 - 01:52 AM

View Postmrsafraz, on 23 July 2012 - 12:35 AM, said:

I could see in your code that you use
url : "<?php echo Yii::app()->request->baseUrl; ?>/someController/returnView"

Why shouldn't you use
url: "<?php echo $this->createUrl("returnView"); ?>"
instead? (so that the controller name is not hard-coded)

I just revisited my code and saw that the UR for the returnView action in index.php is
  url: "<?php echo '<?php echo '; ?>Yii::app()->request->baseUrl;<?php echo '?>'; ?>/<?php echo $this->class2id($this->modelClass); ?>/returnView",
]
So I can't see where the hard coding is.
0

#16 User is offline   Stefan Syukrillah 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 3
  • Joined: 17-July 12

Posted 03 August 2012 - 03:28 AM

please help me on ajax update dropdownlist with this template was not working at all, i've try on regular yii crud template was running well

on _ajax_form.php
<?php echo $form->dropDownList($model,'id_propinsi', array(""=>"Pilih Propinsi")+CHtml::listData(Refpropinsi::model()->findAll(), 'id', 'nama'),
array( 'ajax' => array(
'type'=>'POST',
'url'=>CController::createUrl('DynKab'),
'update'=>'#Mareal_id_kabupaten', //Mareal[id_kabupaten] Mareal_id_kabupaten
//'data'=>'js:javascript statement'
//leave out the data key to pass all form values through
)
)
);
?>



<?php echo $form->dropDownList($model,'id_kabupaten', array());



on controller:
public function actionDynKab(){
$data=CHtml::listData(Refkabupaten::model()->findAll('id_propinsi=:id_propinsi',array(':id_propinsi'=>(int) $_POST['Mareal']['id_propinsi'])), 'id', 'nama');
foreach($data as $value=>$name)
{echo CHtml::tag('option', array('value'=>$value),CHtml::encode($name),true);}
}
0

#17 User is offline   Stefan Syukrillah 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 3
  • Joined: 17-July 12

Posted 05 August 2012 - 10:39 PM

View PostPartySoft, on 11 May 2012 - 06:32 AM, said:

any hope to update this plugin to work with 1.10 ? it gives some js errors, and breaks down the ajax and fancybox functionality



i've same problem with you that i cannot update ajax dropDownList, and also the datejui that not work...
3 days to find out :(
this is caused by the ID for the FORM at _ajax_form.php and the ID of FORM at Search form have same name
ex: my ajax_form id Mareal_kabupaten, and at search input ID also Mareal_kabupaten

then when ajax or datejui update the form identify the ID Mareal_kabupaten then ajax or datejui update the first ID found, the first ID was at search FORM, then it's funny that input form have option :)

solution: try to remark everything about SEARCH form
in my case : i just remark this at index.php
<?php
/*Yii::app()->clientScript->registerScript('search', "
$('.search-button').click(function(){
$('.search-form').toggle();
return false;
});
$('.search-form form').submit(function(){
$.fn.yiiGridView.update('mareal-grid', {
data: $(this).serialize()
});
return false;
});
");*/
?>
<h1>Mareals </h1>
<?php /*?> <p class="left">You may optionally enter a comparison operator (<b>&lt;</b>, <b>&lt;=</b>, <b>&gt;</b>, <b>&gt;=</b>, <b>&lt;&gt;</b>
or <b>=</b>) at the beginning of each of your search values to specify how the comparison should be done.</p><?php echo CHtml::link('Advanced Search','#',array('class'=>'search-button')); ?><div class="search-form" style="display:none">
<?php $this->renderPartial('_search',array(
'model'=>$model,
)); ?>
</div><!-- search-form --><?php */?>

i just remark all search form and.... ALL WORKS... I AM VERRY HAPPY... 3 days working with good result :D

and for you drumaddict who create this ajaxgiicrud... you are the best... made my work eazy with your one page form:)
0

#18 User is offline   cygnet 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 1
  • Joined: 10-May 12

Posted 06 August 2012 - 12:28 AM

wow.. good looking
0

#19 User is offline   Stefan Syukrillah 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 3
  • Joined: 17-July 12

Posted 06 August 2012 - 09:51 PM

And an additional information
you can delete the search.php form and you still can use search function at GRID, then it does not matter if we delete the search form, we can still use grid search text box
0

#20 User is offline   iceinrain 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 13
  • Joined: 18-May 12

Posted 08 September 2012 - 03:36 AM

any idea if mymodel have a composite primary key?
1

Share this topic:


  • (2 Pages)
  • +
  • 1
  • 2
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users