Skip to content

Commit 5d79a22

Browse files
authored
Merge pull request #158 from yajra/fix-fetching-of-editor-table-id
Fix fetching of editor table id.
2 parents 4fe74af + 7da885a commit 5d79a22

File tree

3 files changed

+24
-8
lines changed

3 files changed

+24
-8
lines changed

src/Html/Builder.php

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,10 @@ public function __construct(Repository $config, Factory $view, HtmlBuilder $html
7878
$this->html = $html;
7979
$this->collection = new Collection;
8080
$this->tableAttributes = $this->config->get('datatables-html.table', []);
81+
$this->attributes = [
82+
'serverSide' => true,
83+
'processing' => true,
84+
];
8185
}
8286

8387
/**
@@ -118,7 +122,17 @@ public function generateScripts()
118122
*/
119123
public function generateJson()
120124
{
121-
$args = array_merge(
125+
return $this->parameterize($this->getOptions());
126+
}
127+
128+
/**
129+
* Get DataTable options array.
130+
*
131+
* @return array
132+
*/
133+
public function getOptions()
134+
{
135+
return array_merge(
122136
$this->attributes, [
123137
'ajax' => $this->ajax,
124138
'columns' => $this->collection->map(function (Column $column) {
@@ -129,8 +143,6 @@ public function generateJson()
129143
})->toArray(),
130144
]
131145
);
132-
133-
return $this->parameterize($args);
134146
}
135147

136148
/**

src/Html/Editor/Editor.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -264,10 +264,6 @@ public function toJson($options = 0)
264264
$replacements = [];
265265

266266
foreach (Arr::dot($parameters) as $key => $value) {
267-
if ($key === 'table') {
268-
Arr::set($parameters, $key, '#' . $value);
269-
}
270-
271267
if ($this->isCallbackFunction($value, $key)) {
272268
$values[] = trim($value);
273269
Arr::set($parameters, $key, '%' . $key . '%');

src/Html/HasEditor.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ protected function newEditor($fields)
6868
}
6969

7070
if (! $editor->table) {
71-
$editor->table($this->getTableAttribute('id'));
71+
$editor->table('#' . $this->getTableAttribute('id'));
7272
}
7373

7474
if (! $editor->ajax) {
@@ -77,4 +77,12 @@ protected function newEditor($fields)
7777

7878
return $editor;
7979
}
80+
81+
/**
82+
* @return array|null
83+
*/
84+
public function getEditors()
85+
{
86+
return $this->editors;
87+
}
8088
}

0 commit comments

Comments
 (0)