Maslosoft Framework Logo Maslosoft Framework Documentation
Flexible Application Foundation


Tree Grid

Tree grid is a hibrid between Action Tree and Grid View

This allows displaying tree structure along with additional columns containing attributes or actions.

In example below drag'n'drop is enabled, tree nodes can be moved around by dragging by icon. Notice that tree grid uses DataProvider not DataProvider like Action Tree.

The TreeGrid is very similar to Grid View, including column renderers and configuration for custom renderers

No items found
Title Published
echo TreeGrid::widget([
	'dataProvider' => new DataProvider(new PageItemTree),
	'nodesField' => 'title',
	'dnd' => true,
	'columns' => [
		'title',
		'published'
	]
]);

Initialization types

By dataProvider

Most obvious initialization of TreeGrid is by passing DataProvider to $dataProvider. This will ensure that data is reloaded on remote action forwarding.

This means that grid might reset on remote actions

When parameter $model is provided along with $dataProvider, TreeGrid will update property children of $model with actual tree state before sending AJAX request.

Use this kind of initialization when:

  • Displaying data
  • Need to update grid state via forwarded remote actions
  • When using drag and drop without forwarded remote action
  • Working with data provider
By model

When property $model is set, TreeGrid expects model with children property, containing tree structure. With this kind of initialization, grid state will be persisted on remote actions.

Grid will not be updated on forwarded remote actions

Use this kind of initialization when:

  • Working with drag and drop tree and remote actions
  • Forwarded remote actions might be called while working on structure
  • Working with model