Jump to content
Дизайн и модификация IPS Community IPBSkinsBETA
Search In
  • More options...
Find results that contain...
Find results in...
Sign in to follow this  
siv1987

Сортировка элементов в таблице

Recommended Posts

Камрады, кто знает можно ли таблице типа \IPS\Helpers\Table\Db сделать пользовательскую сортировку элементов на подобие нодов?

Share this post


Link to post
Share on other sites

Теоритически можно.

Если не особо принципиально, как будет сделано, то я бы добавил кнопку для сортировки + метод с формой, где использовал \IPS\Helpers\Form\Sort

  • Upvote 1

Share this post


Link to post
Share on other sites

С таблицой наверное только так. Либо Table заменить на \IPS\Helpers\Tree\Tree

Share this post


Link to post
Share on other sites

Сделал два варианта - с Table и Tree, посмотрим какой больше зайдет.

$tree = new \IPS\Helpers\Tree\Tree(
	$url,
	\IPS\Member::loggedIn()->language()->addToStack( 'menu__smsverification_gateways_manage' ),
	/* Get Roots */
	function() use ( $url )
	{
		$rows = array();
		
		foreach( \IPS\Db::i()->select( '*', 'smsverification_gateways', null, 'position ASC' ) as $row )
		{
			$url = $url->setQueryString( [ 'id' => $row['id'] ] );
		
			$rows[ $row['id'] ] = \IPS\Theme::i()->getTemplate( 'trees', 'core' )->row( $url, $row['id'], \IPS\Member::loggedIn()->language()->addToStack( 'smsgateway_'.$row['gateway'] ), FALSE, 
				array(
					'edit'	=> array(
						'icon'		=> 'pencil',
						'title'		=> 'edit',
						'link'		=> $url->setQueryString( array( 'do' => 'edit' ) ),
						'data' 		=> array( 
							'ipDialog' => '',
							'ipsDialog-title' => \IPS\Member::loggedIn()->language()->addToStack('edit') 
						),
					),
					'delete'	=> array(
						'icon'		=> 'times-circle',
						'title'		=> 'delete',
						'link'		=> $url->setQueryString( array( 'do' => 'delete' ) ),
						'data'		=> array( 'delete' => '' )
					),
				), null, null, $row['position'], NULL, TRUE );
		}
		
		return $rows;
	},
	/* Get Row */
	function( )
	{
		
	},
	/* Get Row's Parent ID */
	function()
	{
		return NULL;
	},
	/* Get Children */
	function( $key )
	{
		return NULL;
	},
	/* Get Root Buttons */
	function() 
	{
		return array(
			'add'	=> array(
				'icon'		=> 'plus',
				'title'		=> 'smsverify_new_gateway',
				'link'		=> \IPS\Http\Url::internal( "app=smsverification&module=gateways&controller=manage&do=add" ),
				'data'		=> array( 
					'ipsDialog' => '',
					'ipsDialog-title' => \IPS\Member::loggedIn()->language()->addToStack('smsverify_new_gateway_title') 
				)
			),
		);
	},
	FALSE,
	TRUE,
	TRUE
);

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...