承接 tomkirsch/sorter 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

tomkirsch/sorter

Composer 安装命令:

composer create-project tomkirsch/sorter

包简介

Sorter Library for CI4

README 文档

README

Installation

Add service in App\Config\Services

	public static function sorter(array $tables=[], ?string $url=NULL, $getShared=TRUE){
		$sorter = $getShared ? static::getSharedInstance('sorter', $tables, $url) : new \Tomkirsch\Sorter\Sorter($tables, $url);
		return $sorter;
	}

Usage

In controller, you can access it with the service. You can pass an associative array to setup if you'd like.

	$sorter = service('Sorter');
	// or pass a configuration to save a step:
	$sorter = service('Sorter', [
		'foo'=>'foo_id asc',
		'bar'=>'bar_id asc',
	]);

To add tables, use the addTable() method:

	// add your tables. The "table name" is only used in GET parameters, so it doesn't need to match your database
	$sorter->addTable('foo', 'foo_id', 'asc');
	// you can pass the default sort using a space too:
	$sorter->addTable('bar', 'bar_id asc');

Just all getSort($tableName) to get the current sort field and direction. If none are passed, it'll use the default you specified above.

	// this quick version uses the first table
	$list = model('MyModel')->orderBy($sorter->getSort())->findAll();

	// if you have more than one table, you'll want to pass the name
	$list = model('MyModel')->orderBy($sorter->getSort('foo'))->findAll();

In your view, use QuickTable to configure columns, templates, and output the thead and tbody:

<?php
$qt = $sorter->quickTable('foo') // pass the table name, or you can omit for only 1 table
	// define your columns and how you'd like the values to be formatted...
	// simple
	->addCol('customer_id', 'Customer Number')

	// template with variable substitution
	->addCol('customer_address', 'Address', 'asc', '$customer_address<br>$customer_city')

	// typical formats
	->addCol('iscash', 		'Cash', 		'desc', 'yesno')
	->addCol('amount', 		'Amount', 		'desc', 'money')
	->addCol('balance', 	'Balance', 		'desc', 'balance') // negative values are shown with parentheses
	->addCol('widgetcount', '# of Widgets', 'desc', 'number')	// number with grouped thousands
	->addCol('ph_level', 	'pH', 			'desc', 'number|1') // 1 decimal place (arguments separated by pipe)
	->addCol('created', 	'Created', 		'desc', 'datetime')
	->addCol('thetime', 	'Time', 		'desc', 'time')
	->addCol('schedule', 	'Sched Date', 	'desc', 'dateFormat|D m/d') // custom date format (arguments separated by pipe)

	// closure (most flexible - however you MUST return TD tags)
	->addCol('customer_iscash', 'Cash', 'desc', function($value, $row){
		return '<td class="bg-success">'.($value ? 'Yes' : 'No').'</td>';
	})

	// you can also define a closure for the opening <tr> tag:
	->rowTemplate(function($row){
		return '<tr data-foobar="'.$row->id.'">';
	})
;
?>
<?= $qt->table($list, 'class="table table-bordered"') ?>

For more control, you can also build links in your view using anchorIcon(), anchor(), url(), queryString() or queryArray()

	<th><?= $sorter->anchorIcon('category_ordernum desc', 'Order') ?></th>

	// or if you have more than one table:
	<th><?= $sorter->anchorIcon('category_ordernum desc', 'Order', '', 'cat') ?></th>

Look at these methods in the class for more usage (GET parameters, HTML attributes, etc)

tomkirsch/sorter 适用场景与选型建议

tomkirsch/sorter 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 31 次下载、GitHub Stars 达 0, 最近一次更新时间为 2021 年 02 月 19 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 tomkirsch/sorter 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 tomkirsch/sorter 我们能提供哪些服务?
定制开发 / 二次开发

基于 tomkirsch/sorter 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 31
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 8
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-02-19