Skip to content
This repository has been archived by the owner on Aug 8, 2021. It is now read-only.

Commit

Permalink
resolved #40
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaohuilam committed Sep 16, 2020
1 parent ba8f6df commit 5167334
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
4 changes: 2 additions & 2 deletions resources/views/filter_select.blade.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<span class="dropdown select2-filter" id="filter_select_user_id_span">
<span class="dropdown select2-filter" id="filter_select_{{$column}}_span">
<form action="{{$uri}}" pjax-container style="display: inline-block;">
<a href="javascript:void(0);" class="dropdown-toggle " data-toggle="dropdown" aria-expanded="true">
<i class="fa fa-filter"></i>
</a>
<ul class="dropdown-menu" role="menu" style="padding: 10px;box-shadow: 0 2px 3px 0 rgba(0,0,0,.2);left: -70px;border-radius: 0;">
<li>
<select type="text" class="form-control input-sm column-filter-user-id" name="user_id" id="filter_select2_user_id" value="' . request()->get('user_id') . '" style="width: 100%" autocomplete="off"/>
<select type="text" class="form-control input-sm column-filter-{{$column}}" name="{{$column}}" id="filter_select2_{{$column}}" value="{{request()->get($column)}}" style="width: 100%" autocomplete="off"/>
</li>
<li class="divider">
</li><li class="text-right">
Expand Down
15 changes: 8 additions & 7 deletions src/Grid/Select2Filter.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,13 @@ class Select2Filter extends AbstractDisplayer
*/
public function display()
{
Admin::js(assets('vendor/laravel-admin-ext/laravel-admin-select2/filter-select.js'), true, true);
Admin::script('window.select2_filter("' . $this->column->getName() . '")', true);
$arguments = func_get_args();
$column = $this->column->getName();

if (isset($this->column->has_filter_select)) {
return '';
return $this->row->{$column};
}
$arguments = func_get_args();
$options = Arr::first($arguments);
$column = $this->column->getName();

if (request()->get('_search_' . $column)) {
$query = call_user_func($options, request()->input('keyword'));
Expand All @@ -35,9 +33,12 @@ public function display()
//throw new HttpResponseException(response()->json($query->paginate()));
}

$this->column->addHeader(view('laravel-admin-select2::filter_select', ['uri' => $this->getFormAction($column),]));
$this->column->addHeader(view('laravel-admin-select2::filter_select', ['column' => $column, 'uri' => $this->getFormAction($column),]));
$this->column->has_filter_select = true;
return '';

Admin::js(assets('vendor/laravel-admin-ext/laravel-admin-select2/filter-select.js'), true, true);
Admin::script('window.select2_filter("' . $this->column->getName() . '")', true);
return $this->row->{$column};
}

/**
Expand Down

0 comments on commit 5167334

Please sign in to comment.