Skip to content

Commit 379060c

Browse files
authored
Added setRowId description
Added the setRowId documentation mentioned in yajra/laravel-datatables#2661 (comment)
1 parent 2e7080f commit 379060c

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

index-column.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,20 @@ Route::get('user-data', function() {
1616
```
1717

1818
Using `addIndexColumn` will add another column on your response with a column name that is set on [`index_column`](/docs/{{package}}/{{version}}/general-settings#index-column) configuration.
19-
The default index column name is `DT_RowIndex`
19+
The default index column name is `DT_RowIndex`.
20+
21+
If you want to customize the index used by the `DT_RowIndex`, you can use `setRowId('COLUMN')` to change the index number.
22+
23+
```php
24+
use DataTables;
25+
26+
Route::get('user-data', function() {
27+
$model = App\User::query();
28+
29+
return DataTables::eloquent($model)
30+
->setRowId('id')
31+
->toJson();
32+
});
33+
```
34+
35+
Be careful with this option, an index should be unique and an integer to be useful for DataTables.

0 commit comments

Comments
 (0)