File tree Expand file tree Collapse file tree 2 files changed +31
-0
lines changed Expand file tree Collapse file tree 2 files changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -595,6 +595,20 @@ public function exportFormat(string|callable $format): static
595595 return $ this ;
596596 }
597597
598+ /**
599+ * Set column default content.
600+ *
601+ * @return $this
602+ *
603+ * @see https://datatables.net/reference/option/columns.defaultContent
604+ */
605+ public function defaultContent (string $ content ): static
606+ {
607+ $ this ->attributes ['defaultContent ' ] = $ content ;
608+
609+ return $ this ;
610+ }
611+
598612 public function toArray (): array
599613 {
600614 if (! $ this ->isAuthorized ()) {
Original file line number Diff line number Diff line change @@ -328,4 +328,21 @@ public function it_can_set_template_data(): void
328328 $ builder ->generateScripts ()->toHtml ()
329329 );
330330 }
331+
332+ #[Test]
333+ public function it_can_set_column_default_content (): void
334+ {
335+ $ builder = $ this ->getHtmlBuilder ();
336+
337+ $ builder ->columns ([
338+ Column::make ('name ' ),
339+ Column::make ('email ' )->defaultContent ('N/A ' ),
340+ Column::make ('age ' )->defaultContent ('<button><18</button> ' ),
341+ ]);
342+
343+ $ this ->assertCount (3 , $ builder ->getColumns ());
344+ $ this ->assertNull ($ builder ->getColumns ()[0 ]->defaultContent );
345+ $ this ->assertEquals ('N/A ' , $ builder ->getColumns ()[1 ]->defaultContent );
346+ $ this ->assertEquals ('<button><18</button> ' , $ builder ->getColumns ()[2 ]->defaultContent );
347+ }
331348}
You can’t perform that action at this time.
0 commit comments