diff --git a/src/Html/Column.php b/src/Html/Column.php
index 724e3f7..9da4280 100644
--- a/src/Html/Column.php
+++ b/src/Html/Column.php
@@ -595,6 +595,20 @@ public function exportFormat(string|callable $format): static
return $this;
}
+ /**
+ * Set column default content.
+ *
+ * @return $this
+ *
+ * @see https://datatables.net/reference/option/columns.defaultContent
+ */
+ public function defaultContent(string $content): static
+ {
+ $this->attributes['defaultContent'] = $content;
+
+ return $this;
+ }
+
public function toArray(): array
{
if (! $this->isAuthorized()) {
diff --git a/tests/Html/Builder/BuilderTest.php b/tests/Html/Builder/BuilderTest.php
index f1ea1cf..ab5cd5e 100644
--- a/tests/Html/Builder/BuilderTest.php
+++ b/tests/Html/Builder/BuilderTest.php
@@ -328,4 +328,21 @@ public function it_can_set_template_data(): void
$builder->generateScripts()->toHtml()
);
}
+
+ #[Test]
+ public function it_can_set_column_default_content(): void
+ {
+ $builder = $this->getHtmlBuilder();
+
+ $builder->columns([
+ Column::make('name'),
+ Column::make('email')->defaultContent('N/A'),
+ Column::make('age')->defaultContent(''),
+ ]);
+
+ $this->assertCount(3, $builder->getColumns());
+ $this->assertNull($builder->getColumns()[0]->defaultContent);
+ $this->assertEquals('N/A', $builder->getColumns()[1]->defaultContent);
+ $this->assertEquals('', $builder->getColumns()[2]->defaultContent);
+ }
}