在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:kabasakalis/yii-ajax-crud-behavior开源软件地址:https://github.com/kabasakalis/yii-ajax-crud-behavior开源编程语言:JavaScript 83.0%开源软件介绍:AjaxCrudBehaviorSingle Page CRUD operations on ActiveRecord models with controller behavior inherited AJAX actions © 2013 Spiros Kabasakalis LIVE DEMOOverviewCreate, update and view details of records in a fancybox pop up. Single and bulk deletions with modal dialog prompt (noty plugin). This is actually a complete rewrite of my ajaxcrudgiitemplate extension. Instead of gii generated files,I wrote a reusable behavior that adds controller actions and eliminates repetition of code across different controllers.Javascript has been moved to a js file resulting in cleaner code. ##Requirements Yii 1.1.12 or above,may work with older versions too. Setup.
public function search($pagination)
{
// Warning: Please modify the following code to remove attributes that
// should not be searched.
$criteria=new CDbCriteria;
//example,fill in with your model property names.
$criteria->compare('id',$this->id,true);
$criteria->compare('name',$this->name,true);
$criteria->compare('description',$this->description,true);
$criteria->compare('price',$this->price,true);
return new CActiveDataProvider($this, array(
'criteria'=>$criteria,
'pagination' => array(
'pageSize' =>$pagination,
),
));
}
class [ MODEL CLASS NAME ] Controller extends BaseController
{
public function init(){
$this->ajaxCrudBehavior->register_Js_Css();
parent::init();
}
public function behaviors()
{
return array(
'ajaxCrudBehavior' => array('class' => 'application.behaviors.AjaxCrudBehavior',
'modelClassName' =>'[MODEL CLASS NAME(ex.Product)]',
'form_alias_path' =>'[FORM PATH ALIAS (ex.application.views.product._form)]',
'view_alias_path' =>'[VIEW PATH ALIAS (ex.application.views.product._view)]' ,
'pagination'=>'10' //page size for CGridView pagination
)
);
}
...
Your controller code
...
} Templates for the form and view files are provided,you will only need to modify property names and input fields for your specific model and copy to view folder of your controller.
|
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论