@@ -55,6 +55,7 @@ public function __construct(array $attrs = []) {
5555 ':length ' => 'page.pages_count ' ,
5656 '@input ' => 'loadPage '
5757 ]);
58+ $ this ->setHasFooter (false );
5859 }
5960 /**
6061 * Sets the name of JavaScript function that will be get executed when
@@ -63,9 +64,12 @@ public function __construct(array $attrs = []) {
6364 * Note that the first parameter of the function will be page number.
6465 *
6566 * @param string $func
67+ *
68+ * @return VDataTable
6669 */
67- public function setOnPageNumberClick (string $ func ) {
70+ public function setOnPageNumberClick (string $ func ) : VDataTable {
6871 $ this ->getVPagination ()->setAttribute ('@input ' , $ func );
72+ return $ this ;
6973 }
7074 /**
7175 * Adds support for expanding table rows.
@@ -104,22 +108,27 @@ public function addExpandedRow($el, string $expandedCallback = null) : HTMLNode
104108 *
105109 * @param string|HTMLNode $el The element that will be added to the slot.
106110 *
111+ * @param array $attrs An optional array of attributes to set for the element.
112+ *
107113 * @return HTMLNode The method will return an object of type HTMLNode
108114 * that represents the added element.
109115 */
110- public function addItemSlot (string $ slot , $ el ) : HTMLNode {
116+ public function addItemSlot (string $ slot , $ el, array $ attrs = [] ) : HTMLNode {
111117 return $ this ->addChild ('template ' , [
112118 '#item. ' .$ slot => '{ item } '
113- ])->addChild ($ el );
119+ ])->addChild ($ el, $ attrs );
114120 }
115121 /**
116122 * Sets the name of JavaScript function that will be get executed when
117123 * page size input changes value.
118124 *
119125 * @param string $func
126+ *
127+ * @return VDataTable
120128 */
121- public function setOnPageSizeChanged (string $ func ) {
129+ public function setOnPageSizeChanged (string $ func ) : VDataTable {
122130 $ this ->getPageSizeInput ()->setAttribute ('@input ' , $ func );
131+ return $ this ;
123132 }
124133 /**
125134 * Returns the node that represents the footer of the table.
@@ -157,8 +166,10 @@ public function getPageSizeInput() : HTMLNode {
157166 * <li>pages_options: An array that contain number of items per page like 5, 10, 20</li>
158167 * </ul>
159168 * @param string $name Name of the model. Defined in 'data' section.
169+ *
170+ * @return VDataTable
160171 */
161- public function setPagingModel (string $ name ) {
172+ public function setPagingModel (string $ name ) : VDataTable {
162173 $ this ->getVPagination ()->setAttributes ([
163174 'v-model ' => $ name .'.page_number ' ,
164175 ':length ' => $ name .'.pages_count ' ,
@@ -172,29 +183,37 @@ public function setPagingModel(string $name) {
172183 ':items-per-page ' => $ name .'.size ' ,
173184 ]);
174185 $ this ->paginationModelName = $ name ;
186+ return $ this ;
175187 }
176188 /**
177189 * Sets if the table will have a footer or not.
178190 *
179191 * @param bool $withFooter If true is passed, the table will have footer.
180192 * Other than that, the table will not have footer.
193+ *
194+ * @return VDataTable
181195 */
182- public function setHasFooter (bool $ withFooter ) {
196+ public function setHasFooter (bool $ withFooter ) : VDataTable {
183197 if ($ withFooter && $ this ->getFooter ()->getParent () === null ) {
184198 $ this ->addChild ($ this ->getFooter ());
185199 $ this ->setAttribute (':items-per-page ' , $ this ->paginationModelName .'.size ' );
186200 } else {
187201 $ this ->removeChild ($ this ->getFooter ());
188202 $ this ->removeAttribute (':items-per-page ' );
189203 }
204+
205+ return $ this ;
190206 }
191207 /**
192208 * Sets the properties of the v-select which is used to select items
193209 * per page.
194210 *
195211 * @param array $attrs
212+ *
213+ * @return VDataTable
196214 */
197- public function setPageSizeInputProps (array $ attrs ) {
215+ public function setPageSizeInputProps (array $ attrs ) : VDataTable {
198216 $ this ->pageSizeSelect ->setAttributes ($ attrs );
217+ return $ this ;
199218 }
200219}
0 commit comments