Skip to content

Commit e768bec

Browse files
committed
treeview item methods
1 parent f5a22fd commit e768bec

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

src/Widgets/TreeView/TreeView.php

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,4 +132,48 @@ public function selected(): array
132132
}
133133
return explode(' ', $result);
134134
}
135+
136+
/**
137+
* Returns the ID of the parent of item.
138+
*
139+
* @return string The ID or empty string.
140+
*/
141+
public function getParentItemId(string $itemId): string
142+
{
143+
return $this->call('parent', $itemId);
144+
}
145+
146+
public function isRootItem(string $itemId): bool
147+
{
148+
return $this->getParentItemId($itemId) === '';
149+
}
150+
151+
/**
152+
* Returns the ID of item's next sibling.
153+
*
154+
* @return string the ID or empty string.
155+
*/
156+
public function getNextItemId(string $itemId): string
157+
{
158+
return $this->call('next', $itemId);
159+
}
160+
161+
/**
162+
* Returns the ID of item's previous sibling.
163+
*
164+
* @return string the ID or empty string.
165+
*/
166+
public function getPrevItemId(string $itemId): string
167+
{
168+
return $this->call('prev', $itemId);
169+
}
170+
171+
/**
172+
* Sets the viewport to the specified item.
173+
*/
174+
public function seeItemId(string $itemId): static
175+
{
176+
$this->call('see', $itemId);
177+
return $this;
178+
}
135179
}

0 commit comments

Comments
 (0)