filterModel自动搜索机制
来源:互联网 发布:游戏程序员工资多少 编辑:程序博客网 时间:2024/06/11 18:18
失去焦点后会自动搜索内容
1、前端实现
GridView中绑定yiiGridView方法,获取Url和Get数据,当input输入框失去焦点的时候,会有相应的方法建立Form表单,能够提交input输入框中的内容,提交地址是原来获取的Url(自己对于json具体实现函数不太理解,只有把答题思路讲出来)
2、后台实现
Controller中:
public function actionIndex() { $searchModel = new CategorySearch(); $dataProvider = $searchModel->search(Yii::$app->request->queryParams); return $this->render('index', [ 'searchModel' => $searchModel, 'dataProvider' => $dataProvider, ]); }
实例化CategorySearch类,之后调用search()方法,找到search方法
public function search($params) { $query = Category::find(); // add conditions that should always apply here $dataProvider = new ActiveDataProvider([ 'query' => $query, ]); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to return any records when validation fails // $query->where('0=1'); return $dataProvider; } // grid filtering conditions $query->andFilterWhere([ 'id' => $this->id, ]); $query->andFilterWhere(['like', 'name', $this->name]); return $dataProvider; }}
流程:
1、find()数据
2、建立数据模型
3、给模型属性赋值load()
4、验证validate()
5、SQL查询andFilterWhere()
6、返回数据模型
阅读全文
0 0
- filterModel自动搜索机制
- 脑自动处理机制——信息的自动搜索与自动提取(略谈)
- 搜索框自动搜索 -ionic
- iOS,viewWithTag搜索机制
- 垃圾搜索机制
- 自动搜索调频收音机
- 自动搜索问题
- 网络文章自动搜索
- ajxa自动搜索功能
- ajax自动搜索功能
- ASP.NET+自动搜索
- 局域网自动搜索服务器
- combo 自动搜索
- 简单自动搜索内容
- 回车自动搜索
- Ajax搜索自动提示
- 搜索内容自动匹配
- 搜索自动提示
- React Native热更新方案
- linux usb设备驱动(1)
- Swift: 消除警告-Scene is unreachable due to lack of entry points and does not have an identifier for
- 汇编之寄存器
- 【备忘】2017最新传智播客黑马java 32期基础就业班视频教程
- filterModel自动搜索机制
- VM中的Ubuntu配置置固定IP(NAT方式)
- 用最简单且兼容性最好的方式去实现dialog的有序列表
- SOA开发-001应用基本规范
- ZooKeeper的安装与部署
- 图像处理之特殊灰度算法技巧
- 第三章 授权——跟我学习springmvc shiro mybatis
- 【深入理解反向传播BP】Calculus on Computational Graphs: Backpropagation
- 阅读清单