andrelohmann-silverstripe/bootstrap_orderable_frontend

前端可排序分页列表

1.0.1 2016-03-22 00:08 UTC

This package is auto-updated.

Last update: 2024-08-29 04:48:46 UTC


README

维护者

  • Andre Lohmann(昵称:andrelohmann)

要求

Silverstripe 3.2.x

概述

本模块提供了一种构建前端可排序集合的良好范式。可排序列表将是分页和异步的(

使用方法

在控制器动作中创建一个OrderablePaginatedList并添加一个异步语句

class MyController extends Controller {
	
	...

	public function orderableobjects(){
		
        $List = MyOrderableObject::get()->sort('Sort');
        $MyOrderableObjects = new OrderablePaginatedList($List, $this->request);
		$MyOrderableObjects->setPageLength(10)->setSortField('Sort');
        // if the sortable list is a many many relation
        // $MyOrderableObjects->setOwner($OwnerObject)->setManyMany('NAME_OF_MANY_MANY_RELATION');
		
		if($this->request->isAjax()) {
			return $this->customise(array(
                "Objects" => $MyOrderableObjects->process(), // process the ordering after OrderablePaginatedList has all information it needs (pageLength, SortField, Owner, ManyManyRelation)
				"URL" => $this->request->getURL(true) // add this for BackURL parameter
            ))->renderWith('OrderableObjectsList');
		}
		
		return $this->customise(new ArrayData(array(
			"Title" => "My Orderable Objects",
			"Objects" => $MyOrderableObjects,
			"URL" => $this->request->getURL(true) // add this for BackURL parameter
		)))->renderWith(
			array('Page_orderableobjects', $this->stat('template_main'), $this->stat('template'))
        );
	}

使用模板Layout/Page_orderableobjects.ss和templates/Includes/OrderableObjectsList.ss作为基础模板来构建您自己的可排序分页列表

注意

此仓库使用git flow范式。在每个发布周期之后,请勿忘记将标签、master和develop推送到远程原点

git push --tags
git push origin develop
git push origin master