当前位置:网站首页>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 .
边栏推荐
- XSS range (II) xss.haozi
- Cuda-npp image and video processing
- 新版海螺影视主题模板M3.1全解密版本多功能苹果CMSv10后台自适应主题开源全解密版
- Why is redis fast? Message queue, single thread
- 多重继承与派生类成员标识
- MySQL和Redis的双写一致性
- Qt编写物联网管理平台48-特色功能设计
- owt-server源码剖析(三)--video模块分析之Mixer In
- Multimodal unsupervised image to image translation
- 矿山开采虚拟现实vr安全培训提升员工警惕性和防护意识
猜你喜欢

2022/07/28 学习笔记 (day18) 常用API

STM32C8T6编码器电机测速与arduino光电模块测速

Talk about 11 tips for interface performance optimization

Understanding service governance in distributed development

Production scheme and advantages of online 3D digital exhibition hall

where、having、group by、order by,is null,not in,子查询,delete,日期函数

laravel框架中实现封装公共方法全局调用

Double write consistency of MySQL and redis

MQTT例程

ES6 detailed quick start!
随机推荐
Branch management practice of "two pizza" team
6年测试经验,教大家测试~如何把控项目
NVIDIA-VPI(Vision Programming Interface)
Driverless obstacle avoidance technology
owt-server源码剖析(三)--video模块分析之Mixer In
How to use RPA to achieve automatic customer acquisition?
Summary of knowledge points of Engineering Economics
Virsh console connection failure
Others' happiness
What are the TCP retransmission mechanisms?
物联网组件
Multimodal unsupervised image to image translation
JMeter's BeanShell generates MD5 encrypted data and writes it to the database
Code implementation - the greatest common factor of polynomials (linear algebra)
Stm32f103xx firmware function library-1
I want to talk about high concurrency.
ES6 detailed quick start!
Remember error scheduler once Asynceventqueue: dropping event from queue shared causes OOM
Explain the four asynchronous solutions of JS in detail: callback function, promise, generator, async/await
代码随想录笔记_哈希_349两个数的交集