more fixes on datagrid
This commit is contained in:
parent
efa1e8b716
commit
b596eb1d1b
|
|
@ -42,6 +42,21 @@ class UserComposer
|
||||||
'select' => 'u.id',
|
'select' => 'u.id',
|
||||||
'aliased' => true , //boolean to validate aliasing on the basis of this.
|
'aliased' => true , //boolean to validate aliasing on the basis of this.
|
||||||
'filterable' => [
|
'filterable' => [
|
||||||
|
[
|
||||||
|
'column' => 'u.email',
|
||||||
|
'type' => 'string',
|
||||||
|
'label' => 'Admin E-Mail'
|
||||||
|
], [
|
||||||
|
'column' => 'u.name',
|
||||||
|
'type' => 'string',
|
||||||
|
'label' => 'Admin Name'
|
||||||
|
], [
|
||||||
|
'column' => 'u.id',
|
||||||
|
'type' => 'number',
|
||||||
|
'label' => 'Admin ID'
|
||||||
|
]
|
||||||
|
],
|
||||||
|
'searchable' => [
|
||||||
[
|
[
|
||||||
'column' => 'u.email',
|
'column' => 'u.email',
|
||||||
'type' => 'string',
|
'type' => 'string',
|
||||||
|
|
|
||||||
|
|
@ -88,9 +88,9 @@ class DataGrid
|
||||||
{
|
{
|
||||||
// list($name, $select, $table, $join, $columns) = array_values($args);
|
// list($name, $select, $table, $join, $columns) = array_values($args);
|
||||||
$name = $select = $aliased = $table = false;
|
$name = $select = $aliased = $table = false;
|
||||||
$join = $columns = $filterable = $css = $operators = [];
|
$join = $columns = $filterable = $searchable = $css = $operators = [];
|
||||||
extract($args);
|
extract($args);
|
||||||
return $this->build($name, $select, $filterable, $aliased, $table, $join, $columns, $css, $operators);
|
return $this->build($name, $select, $filterable, $searchable, $aliased, $table, $join, $columns, $css, $operators);
|
||||||
}
|
}
|
||||||
|
|
||||||
//starts buikding the queries on the basis of selects, joins and filter with
|
//starts buikding the queries on the basis of selects, joins and filter with
|
||||||
|
|
@ -100,6 +100,7 @@ class DataGrid
|
||||||
$name = null,
|
$name = null,
|
||||||
$select = false,
|
$select = false,
|
||||||
array $filterable = [],
|
array $filterable = [],
|
||||||
|
array $searchable = [],
|
||||||
bool $aliased = false,
|
bool $aliased = false,
|
||||||
$table = null,
|
$table = null,
|
||||||
array $join = [],
|
array $join = [],
|
||||||
|
|
@ -109,10 +110,10 @@ class DataGrid
|
||||||
Pagination $pagination = null
|
Pagination $pagination = null
|
||||||
) {
|
) {
|
||||||
$this->request = Request::capture();
|
$this->request = Request::capture();
|
||||||
|
|
||||||
$this->setName($name);
|
$this->setName($name);
|
||||||
$this->setSelect($select);
|
$this->setSelect($select);
|
||||||
$this->setFilterable($filterable);
|
$this->setFilterable($filterable);
|
||||||
|
$this->setSearchable($filterable);
|
||||||
$this->setAlias($aliased);
|
$this->setAlias($aliased);
|
||||||
$this->setTable($table);
|
$this->setTable($table);
|
||||||
$this->setJoin($join);
|
$this->setJoin($join);
|
||||||
|
|
@ -158,6 +159,16 @@ class DataGrid
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set Searchable columns
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
|
||||||
|
public function setSearchable($searchable) {
|
||||||
|
$this->searchable = $searchable ?: [];
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set alias parameter
|
* Set alias parameter
|
||||||
* to know whether
|
* to know whether
|
||||||
|
|
@ -384,7 +395,7 @@ class DataGrid
|
||||||
foreach ($parsed as $k=>$v) {
|
foreach ($parsed as $k=>$v) {
|
||||||
parse_str($v, $parsed[$k]);
|
parse_str($v, $parsed[$k]);
|
||||||
}
|
}
|
||||||
|
// dump($parsed);
|
||||||
foreach ($parsed as $key => $value) {
|
foreach ($parsed as $key => $value) {
|
||||||
foreach ($value as $column => $filter) {
|
foreach ($value as $column => $filter) {
|
||||||
if (array_keys($filter)[0]=="like") {
|
if (array_keys($filter)[0]=="like") {
|
||||||
|
|
@ -398,7 +409,21 @@ class DataGrid
|
||||||
str_replace('_', '.', $column), //replace the logic of making the column name and consider the case for _
|
str_replace('_', '.', $column), //replace the logic of making the column name and consider the case for _
|
||||||
array_values($filter)[0]
|
array_values($filter)[0]
|
||||||
);
|
);
|
||||||
} else {
|
}
|
||||||
|
else if($column == "search") {
|
||||||
|
foreach($this->searchable as $search)
|
||||||
|
{
|
||||||
|
// dump($search['column'],array_values($filter)[0]);
|
||||||
|
$this->query->orWhere(
|
||||||
|
$search['column'],
|
||||||
|
$this->operators['like'],
|
||||||
|
'%'.array_values($filter)[0].'%'
|
||||||
|
);
|
||||||
|
// $this->results = $this->query->get();
|
||||||
|
// dd($this->results);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
$this->query->where(
|
$this->query->where(
|
||||||
str_replace('_', '.', $column),
|
str_replace('_', '.', $column),
|
||||||
$this->operators[array_keys($filter)[0]],
|
$this->operators[array_keys($filter)[0]],
|
||||||
|
|
|
||||||
|
|
@ -109,9 +109,7 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="filter-row-two">
|
<div class="filter-row-two">
|
||||||
{{-- {{ $columns }}<br/>
|
{{-- <span class="filter-one">
|
||||||
{{ json_encode($operators) }} --}}
|
|
||||||
<span class="filter-one">
|
|
||||||
<span class="filter-name">
|
<span class="filter-name">
|
||||||
Stock
|
Stock
|
||||||
</span>
|
</span>
|
||||||
|
|
@ -119,7 +117,7 @@
|
||||||
Available
|
Available
|
||||||
<span class="icon cross-icon"></span>
|
<span class="icon cross-icon"></span>
|
||||||
</span>
|
</span>
|
||||||
</span>
|
</span> --}}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="table">
|
<div class="table">
|
||||||
|
|
@ -160,7 +158,7 @@
|
||||||
@section('javascript')
|
@section('javascript')
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
var allFilters1 = [];
|
var allFilters1 = [];
|
||||||
var filter_value;
|
var search_value;
|
||||||
var filter_column;
|
var filter_column;
|
||||||
var filter_condition;
|
var filter_condition;
|
||||||
var filter_range;
|
var filter_range;
|
||||||
|
|
@ -184,7 +182,11 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$('.search-btn').click(function(){
|
$('.search-btn').click(function(){
|
||||||
filter_value = $(".search-field").val();
|
search_value = $(".search-field").val();
|
||||||
|
|
||||||
|
formURL('search','all',search_value,params); //format for search
|
||||||
|
|
||||||
|
alert(search_value);
|
||||||
});
|
});
|
||||||
$('.grid_head').on('click', function(){
|
$('.grid_head').on('click', function(){
|
||||||
|
|
||||||
|
|
@ -192,8 +194,10 @@
|
||||||
var currentSort = $(this).data('column-sort');
|
var currentSort = $(this).data('column-sort');
|
||||||
|
|
||||||
if(currentSort == "asc"){
|
if(currentSort == "asc"){
|
||||||
|
$(this).data('column-name','desc');
|
||||||
formURL(column,'sort','desc',params);
|
formURL(column,'sort','desc',params);
|
||||||
}else{
|
}else{
|
||||||
|
$(this).data('column-name','asc');
|
||||||
formURL(column,'sort','asc',params);
|
formURL(column,'sort','asc',params);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -292,7 +296,6 @@
|
||||||
allFilters1.splice(id,1);
|
allFilters1.splice(id,1);
|
||||||
makeURL(allFilters1);
|
makeURL(allFilters1);
|
||||||
}
|
}
|
||||||
console.log(allFilters1);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue