当前位置:网站首页>Catchadmin practical tutorial (IV) implementation of relevant functions of table components
Catchadmin practical tutorial (IV) implementation of relevant functions of table components
2022-07-29 02:43:00 【Jack_ num1】
1. Sorting function
1.1 Pure page sorting
The official website only provides the sorting function of the current page number of pure pages :#sortable
1.1.1 Example
public function table()
{
// TODO: Implement table() method.
return $this->getTable('bonds')
->header([
// 1. Turn on the function of field sorting
HeaderItem::label(' Number ')->prop('id')->sortable()->width(80),
HeaderItem::label(' Update time ')->prop('updated_at')->sortable()->width(150),
HeaderItem::label(' operation ')->actions([
Actions::delete()
])
])
->withBind()
->withApiRoute('cms/articles')
->withActions([
Actions::create()->to('/cms/articles/detail/')
])
->render();
}
1.2 Custom sort
Custom sorting function : Mainly through API Add to address table The rising and falling values of the fields in the page request to obtain the corresponding response data
1.2.1 add to Method
catch-admin-vue project
src/components/Catch/Table/mixin/operete.jsAddorderChangeMethod
1.2.1.1 Example
// Field sorting
orderChange(column) {
// 1. Set the search sort field
const order_filed = column.prop + '_order'
// 2. Determine sort type
if (column.order === 'ascending') {
// 3. Set the search sort field value
this.queryParams[order_filed] = 'asc'
} else if (column.order === 'descending') {
this.queryParams[order_filed] = 'desc'
} else {
this.queryParams[order_filed] = ''
}
// 4. Re request interface
this.getList()
}
1.2.2 Add event
1.2.2.1 Mode one
stay CatchAdmin project
extend/catcher/library/table/Events.phpAdd events inorderChange
/** * @note: Sort * @return mixed * @time: 2022-07-25 14:57 */
public function orderChange()
{
$this->appendEvents([
'sort-change' => 'orderChange'
]);
return $this;
}
1.2.3 Use the event
public function table()
{
// TODO: Implement table() method.
return $this->getTable('bonds')
->header([
// 1. Turn on the function of field sorting
HeaderItem::label(' Number ')->prop('id')->sortable()->width(80),
HeaderItem::label(' Update time ')->prop('updated_at')->sortable()->width(150),
HeaderItem::label(' operation ')->actions([
Actions::delete()
])
])
->withBind()
// 2. Add an event of sorting change ( Custom sort )
// 2.1 The way 1
->orderChange()
// 2.2 The way 2
->withEvents([
'sort-change' => 'orderChange'
])
->withApiRoute('cms/articles')
->withActions([
Actions::create()->to('/cms/articles/detail/')
])
->render();
}
1.2.3 Example
request URL Example :
/cms/articles?id_order=desc
Here, we can get the request field value in the background_ordersuffix , Determine whether there are sorted fields and sort them accordingly .
边栏推荐
- IOT components
- Qt编写物联网管理平台48-特色功能设计
- owt-server源码剖析(四)--video模块分析之Mixer Out
- Summary of knowledge points of Engineering Economics
- 云开发打工人必备上班摸鱼划水微信小程序源码
- CatchAdmin实战教程(四)Table组件相关功能实现
- Polygon zkEVM——Hermez 2.0简介
- ECCV 2022 | airdet: a small sample target detection method without fine tuning
- Ordinary happiness
- STM32C8T6编码器电机测速与arduino光电模块测速
猜你喜欢

STM32F103 learn the steps and template fool tutorial of 1-keil5 project establishment

FPGA刷题——存储器(RAM和FIFO的Verilog实现)

PHP幸运抽奖系统带后台源码

Exploration and practice of network security vulnerability management

Mqtt routine

h. 264 code stream explanation

HTTP cache

MQTT例程

《微信小程序-进阶篇》Lin-ui组件库源码分析-Button组件(二)

Talk about the implementation principle of feign
随机推荐
I was stunned by this question that I browsed 746000 times
7/28 Gauss elimination to solve linear equations + Gauss elimination to solve XOR linear equations + find the combination number II
OSPF实验
Code random notes_ Hash_ 349 intersection of two numbers
详解异步任务:任务的状态及生命周期管理
Time pit in MySQL driver
owt-server源码剖析(三)--video模块分析之Mixer In
快速掌握Nodejs安装以及入门
童年的快乐时光
Talk about the implementation principle of feign
【无标题】
What are the TCP retransmission mechanisms?
工程经济学简答题
HTTP断点续传以及缓存问题
6-21漏洞利用-mysql弱口令破解
FPGA刷题——存储器(RAM和FIFO的Verilog实现)
漫画算法_小灰灰面试
Kbxxxxx is not necessarily a patch, but also a description of a solution to a problem
2022/07/28 学习笔记 (day18) 常用API
[quality] code quality evaluation standard