You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+76Lines changed: 76 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -169,4 +169,80 @@ return Datatables::of($todo)
169
169
->make();
170
170
```
171
171
172
+
**Example 6: Advanced usage of dataFullSupport**
173
+
174
+
To better utilize dataTables mData (1.9), now columns.data (1.10) feature you may enable dataFullSupport by either setting it to true in the config file, or passing true to the second initialization argument `Datatables::of($query, true)`
175
+
176
+
Creating a table with a searchable and sortable joined table:
177
+
```javascript
178
+
//html
179
+
<table id="user-list"></table>
180
+
//script.js
181
+
$("#users-list").dataTable({
182
+
"processing":true,
183
+
"serverSide":true,
184
+
"ajax":"/api/user/datatables",
185
+
"order": [[1,'desc']],
186
+
"columnDefs": [ { //this prevents errors if the data is null
return $query->join("$table AS $prefix$relation_name", $one, $operator, $two, $type, $where); //->with($relation_name);
237
+
}
238
+
```
239
+
240
+
**Notes on columns.data:**
241
+
- When using the columns.data option the order the data is returned in doesn't matter.
242
+
- You may return extra rows that you use in some tables, and ones you don't without needing to worry about ignoring them.
243
+
- When the data is returned within enbeded arrays, datatables lets you access it using dot notation.
244
+
This allows the columns.data element to address items in your table. The values of the data items are expected to match the columns (or aliases) of the table. For example, if you sort by "profile.last_name" it will use that to sort by the last_name column in the "profiles" table, so make sure that table is joined so the reference exists.
245
+
- If you don't do a direct join you can't sort or search those columns so make sure to set those options to false in the columns array
246
+
- If you eager load the data via Eloquent, you will still get those items back and they may be edit via edit_column just the same without needing to alias the names.
0 commit comments