Skip to content

Multi sortable grid in single page supported! #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
{
"name": "laravel-admin-ext/grid-sortable",
"name": "superoryco/grid-sortable",
"description": "Sort the grid data by drag and drop rows",
"type": "library",
"keywords": ["laravel-admin", "extension", "grid", "sortable"],
"keywords": [
"laravel-admin",
"extension",
"grid",
"sortable"
],
"homepage": "https://github.com/laravel-admin-ext/grid-sortable",
"license": "MIT",
"authors": [
Expand Down Expand Up @@ -31,4 +36,4 @@
]
}
}
}
}
15 changes: 12 additions & 3 deletions src/SaveOrderBtn.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@ protected function script()

$class = str_replace('\\', '\\\\', $class);

$name = $this->getButtonId();

$script = <<<SCRIPT
(function () {

$('.grid-save-order-btn').click(function () {
$('#{$name}').click(function () {

$.post('{$route}', {
_token: $.admin.token,
Expand All @@ -45,12 +47,19 @@ public function render()
{
$this->script();

$name = $this->getButtonId();

$text = __('Save order');

return <<<HTML
<button type="button" class="btn btn-sm btn-info grid-save-order-btn" style="margin-left: 10px;display: none;">
<button id={$name} type="button" class="btn btn-sm btn-info grid-save-order-btn" style="margin-left: 10px;display: none;">
<i class="fa fa-save"></i><span class="hidden-xs">&nbsp;&nbsp;{$text}</span>
</button>
HTML;
}
}

private function getButtonId()
{
return $this->getGrid()->getName() ?: 'grid-save-order-btn';
}
}