datagrid sort and filter fixes

This commit is contained in:
Prashant Singh 2019-01-15 18:55:50 +05:30
parent a3d6e0c37f
commit e48ac7e295
26 changed files with 179 additions and 78 deletions

View File

@ -30,7 +30,7 @@ return [
*
* Accepted Value = integer
*/
'paginate' => false,
'paginate' => true,
'operators' => [
'eq' => "=",

View File

@ -29,6 +29,7 @@ class AttributeDataGrid extends DataGrid
{
$this->addColumn([
'index' => 'id',
'identifier' => 'attribute_id',
'label' => trans('admin::app.datagrid.id'),
'type' => 'number',
'searchable' => false,
@ -38,6 +39,7 @@ class AttributeDataGrid extends DataGrid
$this->addColumn([
'index' => 'code',
'identifier' => 'attribute_code',
'label' => trans('admin::app.datagrid.code'),
'type' => 'string',
'searchable' => true,
@ -47,6 +49,7 @@ class AttributeDataGrid extends DataGrid
$this->addColumn([
'index' => 'admin_name',
'identifier' => 'attribute_name',
'label' => trans('admin::app.datagrid.admin-name'),
'type' => 'string',
'searchable' => true,
@ -56,6 +59,7 @@ class AttributeDataGrid extends DataGrid
$this->addColumn([
'index' => 'type',
'identifier' => 'attribute_type',
'label' => trans('admin::app.datagrid.type'),
'type' => 'string',
'sortable' => true,
@ -65,6 +69,7 @@ class AttributeDataGrid extends DataGrid
$this->addColumn([
'index' => 'is_required',
'identifier' => 'attribute_is_required',
'label' => trans('admin::app.datagrid.required'),
'type' => 'boolean',
'sortable' => true,
@ -80,6 +85,7 @@ class AttributeDataGrid extends DataGrid
$this->addColumn([
'index' => 'is_unique',
'identifier' => 'attribute_is_unique',
'label' => trans('admin::app.datagrid.unique'),
'type' => 'boolean',
'sortable' => true,
@ -95,6 +101,7 @@ class AttributeDataGrid extends DataGrid
$this->addColumn([
'index' => 'value_per_locale',
'identifier' => 'attribute_value_per_locale',
'label' => trans('admin::app.datagrid.per-locale'),
'type' => 'boolean',
'sortable' => true,
@ -110,6 +117,7 @@ class AttributeDataGrid extends DataGrid
$this->addColumn([
'index' => 'value_per_channel',
'identifier' => 'attribute_value_per_channel',
'label' => trans('admin::app.datagrid.per-channel'),
'type' => 'boolean',
'sortable' => true,

View File

@ -28,6 +28,7 @@ class AttributeFamilyDataGrid extends DataGrid
{
$this->addColumn([
'index' => 'id',
'identifier' => 'id',
'label' => trans('admin::app.datagrid.id'),
'type' => 'number',
'searchable' => false,
@ -37,6 +38,7 @@ class AttributeFamilyDataGrid extends DataGrid
$this->addColumn([
'index' => 'code',
'identifier' => 'code',
'label' => trans('admin::app.datagrid.code'),
'type' => 'string',
'searchable' => true,
@ -46,6 +48,7 @@ class AttributeFamilyDataGrid extends DataGrid
$this->addColumn([
'index' => 'name',
'identifier' => 'name',
'label' => trans('admin::app.datagrid.name'),
'type' => 'string',
'searchable' => true,

View File

@ -13,11 +13,11 @@ use DB;
*/
class CategoryDataGrid extends DataGrid
{
protected $index = 'category_id'; //the column that needs to be treated as index column
protected $index = 'id'; //the column that needs to be treated as index column
public function prepareQueryBuilder()
{
$queryBuilder = DB::table('categories as cat')->select('cat.id as category_id', 'ct.name as category_name', 'cat.position as category_position', 'cat.status as category_status', 'ct.locale as category_locale')->leftJoin('category_translations as ct', 'cat.id', '=', 'ct.category_id');
$queryBuilder = DB::table('categories as cat')->select('cat.id', 'ct.name', 'cat.position', 'cat.status', 'ct.locale')->leftJoin('category_translations as ct', 'cat.id', '=', 'ct.category_id');
$this->setQueryBuilder($queryBuilder);
}
@ -25,7 +25,8 @@ class CategoryDataGrid extends DataGrid
public function addColumns()
{
$this->addColumn([
'index' => 'category_id',
'index' => 'cat.id',
'identifier' => 'category_id',
'label' => trans('admin::app.datagrid.id'),
'type' => 'number',
'searchable' => false,
@ -34,7 +35,8 @@ class CategoryDataGrid extends DataGrid
]);
$this->addColumn([
'index' => 'category_name',
'index' => 'ct.name',
'identifier' => 'category_name',
'label' => trans('admin::app.datagrid.name'),
'type' => 'string',
'searchable' => true,
@ -43,7 +45,8 @@ class CategoryDataGrid extends DataGrid
]);
$this->addColumn([
'index' => 'category_position',
'index' => 'cat.position',
'identifier' => 'category_position',
'label' => trans('admin::app.datagrid.position'),
'type' => 'string',
'searchable' => true,
@ -52,7 +55,8 @@ class CategoryDataGrid extends DataGrid
]);
$this->addColumn([
'index' => 'category_status',
'index' => 'cat.status',
'identifier' => 'category_status',
'label' => trans('admin::app.datagrid.status'),
'type' => 'boolean',
'sortable' => true,
@ -67,7 +71,8 @@ class CategoryDataGrid extends DataGrid
]);
$this->addColumn([
'index' => 'category_locale',
'index' => 'ct.position',
'identifier' => 'category_locale',
'label' => trans('admin::app.datagrid.locale'),
'type' => 'boolean',
'sortable' => true,

View File

@ -26,6 +26,7 @@ class ChannelDataGrid extends DataGrid
{
$this->addColumn([
'index' => 'id',
'identifier' => 'id',
'label' => trans('admin::app.datagrid.id'),
'type' => 'number',
'searchable' => false,
@ -35,6 +36,7 @@ class ChannelDataGrid extends DataGrid
$this->addColumn([
'index' => 'code',
'identifier' => 'code',
'label' => trans('admin::app.datagrid.code'),
'type' => 'string',
'searchable' => true,
@ -44,6 +46,7 @@ class ChannelDataGrid extends DataGrid
$this->addColumn([
'index' => 'name',
'identifier' => 'name',
'label' => trans('admin::app.datagrid.name'),
'type' => 'string',
'searchable' => true,
@ -53,6 +56,7 @@ class ChannelDataGrid extends DataGrid
$this->addColumn([
'index' => 'hostname',
'identifier' => 'hostname',
'label' => trans('admin::app.datagrid.hostname'),
'type' => 'string',
'sortable' => true,

View File

@ -26,6 +26,7 @@ class CurrencyDataGrid extends DataGrid
{
$this->addColumn([
'index' => 'id',
'identifier' => 'id',
'label' => trans('admin::app.datagrid.id'),
'type' => 'number',
'searchable' => false,
@ -35,6 +36,7 @@ class CurrencyDataGrid extends DataGrid
$this->addColumn([
'index' => 'name',
'identifier' => 'name',
'label' => trans('admin::app.datagrid.name'),
'type' => 'string',
'searchable' => true,
@ -44,6 +46,7 @@ class CurrencyDataGrid extends DataGrid
$this->addColumn([
'index' => 'code',
'identifier' => 'code',
'label' => trans('admin::app.datagrid.code'),
'type' => 'string',
'searchable' => true,

View File

@ -15,11 +15,11 @@ class CustomerDataGrid extends DataGrid
{
protected $itemsPerPage = 5;
protected $index = 'customer_id'; //the column that needs to be treated as index column
protected $index = 'id'; //the column that needs to be treated as index column
public function prepareQueryBuilder()
{
$queryBuilder = DB::table('customers')->addSelect('customers.id as customer_id', 'customers.email as customer_email', 'customer_groups.name as customer_group_name')->addSelect(DB::raw('CONCAT(customers.first_name, " ", customers.last_name) as customer_full_name'))->leftJoin('customer_groups', 'customers.customer_group_id', '=', 'customer_groups.id');
$queryBuilder = DB::table('customers as custs')->addSelect('custs.id', 'custs.email', 'cg.name')->leftJoin('customer_groups as cg', 'custs.customer_group_id', '=', 'cg.id');
$this->setQueryBuilder($queryBuilder);
}
@ -27,7 +27,8 @@ class CustomerDataGrid extends DataGrid
public function addColumns()
{
$this->addColumn([
'index' => 'customer_id',
'index' => 'custs.id',
'identifier' => 'customer_id',
'label' => trans('admin::app.datagrid.id'),
'type' => 'number',
'searchable' => false,
@ -35,17 +36,18 @@ class CustomerDataGrid extends DataGrid
'width' => '40px'
]);
$this->addColumn([
'index' => 'customer_full_name',
'label' => trans('admin::app.datagrid.name'),
'type' => 'string',
'searchable' => true,
'sortable' => true,
'width' => '100px'
]);
// $this->addColumn([
// 'index' => 'full_name',
// 'label' => trans('admin::app.datagrid.name'),
// 'type' => 'string',
// 'searchable' => true,
// 'sortable' => true,
// 'width' => '100px'
// ]);
$this->addColumn([
'index' => 'customer_email',
'index' => 'custs.email',
'identifier' => 'customer_email',
'label' => trans('admin::app.datagrid.email'),
'type' => 'string',
'searchable' => true,
@ -54,7 +56,8 @@ class CustomerDataGrid extends DataGrid
]);
$this->addColumn([
'index' => 'customer_group_name',
'index' => 'cg.name',
'identifier' => 'customer_group_name',
'label' => trans('admin::app.datagrid.group'),
'type' => 'string',
'searchable' => false,

View File

@ -26,6 +26,7 @@ class CustomerGroupDataGrid extends DataGrid
{
$this->addColumn([
'index' => 'id',
'identifier' => 'id',
'label' => 'ID',
'type' => 'number',
'searchable' => false,
@ -35,6 +36,7 @@ class CustomerGroupDataGrid extends DataGrid
$this->addColumn([
'index' => 'name',
'identifier' => 'name',
'label' => 'Name',
'type' => 'string',
'searchable' => true,

View File

@ -13,11 +13,11 @@ use DB;
*/
class CustomerReviewDataGrid extends DataGrid
{
protected $index = 'product_review_id'; //the column that needs to be treated as index column
protected $index = 'id'; //the column that needs to be treated as index column
public function prepareQueryBuilder()
{
$queryBuilder = DB::table('product_reviews as pr')->addSelect('pr.id as product_review_id', 'pr.title as product_review_title', 'pr.comment as product_review_comment', 'pg.name as product_review_name', 'pr.status as product_review_status')->leftjoin('products_grid as pg', 'pr.product_id', '=', 'pg.id');
$queryBuilder = DB::table('product_reviews as pr')->addSelect('pr.id', 'pr.title', 'pr.comment', 'pg.name', 'pr.status')->leftjoin('products_grid as pg', 'pr.product_id', '=', 'pg.id');
$this->setQueryBuilder($queryBuilder);
}
@ -25,7 +25,8 @@ class CustomerReviewDataGrid extends DataGrid
public function addColumns()
{
$this->addColumn([
'index' => 'product_review_id',
'index' => 'pr.id',
'identifier' => 'product_review_id',
'label' => trans('admin::app.datagrid.id'),
'type' => 'number',
'searchable' => false,
@ -34,7 +35,8 @@ class CustomerReviewDataGrid extends DataGrid
]);
$this->addColumn([
'index' => 'product_review_title',
'index' => 'pr.title',
'identifier' => 'product_review_title',
'label' => trans('admin::app.datagrid.title'),
'type' => 'string',
'searchable' => true,
@ -43,7 +45,8 @@ class CustomerReviewDataGrid extends DataGrid
]);
$this->addColumn([
'index' => 'product_review_comment',
'index' => 'pr.comment',
'identifier' => 'product_review_comment',
'label' => trans('admin::app.datagrid.comment'),
'type' => 'string',
'searchable' => true,
@ -52,7 +55,8 @@ class CustomerReviewDataGrid extends DataGrid
]);
$this->addColumn([
'index' => 'product_review_name',
'index' => 'pg.name',
'identifier' => 'product_name',
'label' => trans('admin::app.datagrid.product-name'),
'type' => 'string',
'searchable' => true,
@ -61,7 +65,8 @@ class CustomerReviewDataGrid extends DataGrid
]);
$this->addColumn([
'index' => 'product_review_status',
'index' => 'pr.status',
'identifier' => 'product_review_status',
'label' => trans('admin::app.datagrid.status'),
'type' => 'boolean',
'searchable' => true,

View File

@ -13,11 +13,11 @@ use DB;
*/
class ExchangeRatesDataGrid extends DataGrid
{
protected $index = 'currency_exch_id';
protected $index = 'id';
public function prepareQueryBuilder()
{
$queryBuilder = DB::table('currency_exchange_rates as cer')->addSelect('cer.id as currency_exch_id', 'curr.name as currency_exch_name', 'cer.rate as currency_exch_rate')->leftJoin('currencies as curr', 'cer.target_currency', '=', 'curr.id');
$queryBuilder = DB::table('currency_exchange_rates as cer')->addSelect('cer.id', 'curr.name', 'cer.rate')->leftJoin('currencies as curr', 'cer.target_currency', '=', 'curr.id');
$this->setQueryBuilder($queryBuilder);
}
@ -25,7 +25,8 @@ class ExchangeRatesDataGrid extends DataGrid
public function addColumns()
{
$this->addColumn([
'index' => 'currency_exch_id',
'index' => 'cer.id',
'identifier' => 'currency_exch_id',
'label' => trans('admin::app.datagrid.id'),
'type' => 'number',
'searchable' => false,
@ -34,7 +35,8 @@ class ExchangeRatesDataGrid extends DataGrid
]);
$this->addColumn([
'index' => 'currency_exch_name',
'index' => 'curr.name',
'identifier' => 'currency_exch_name',
'label' => trans('admin::app.datagrid.currency-name'),
'type' => 'string',
'searchable' => true,
@ -43,7 +45,8 @@ class ExchangeRatesDataGrid extends DataGrid
]);
$this->addColumn([
'index' => 'currency_exch_rate',
'index' => 'cer.rate',
'identifier' => 'currency_exch_rate',
'label' => trans('admin::app.datagrid.exch-rate'),
'type' => 'string',
'searchable' => true,

View File

@ -26,6 +26,7 @@ class InventorySourcesDataGrid extends DataGrid
{
$this->addColumn([
'index' => 'id',
'identifier' => 'id',
'label' => trans('admin::app.datagrid.id'),
'type' => 'number',
'searchable' => false,
@ -35,6 +36,7 @@ class InventorySourcesDataGrid extends DataGrid
$this->addColumn([
'index' => 'code',
'identifier' => 'code',
'label' => trans('admin::app.datagrid.code'),
'type' => 'string',
'searchable' => true,
@ -44,6 +46,7 @@ class InventorySourcesDataGrid extends DataGrid
$this->addColumn([
'index' => 'name',
'identifier' => 'name',
'label' => trans('admin::app.datagrid.name'),
'type' => 'string',
'searchable' => true,
@ -53,6 +56,7 @@ class InventorySourcesDataGrid extends DataGrid
$this->addColumn([
'index' => 'priority',
'identifier' => 'priority',
'label' => trans('admin::app.datagrid.priority'),
'type' => 'string',
'searchable' => true,
@ -62,6 +66,7 @@ class InventorySourcesDataGrid extends DataGrid
$this->addColumn([
'index' => 'status',
'identifier' => 'status',
'label' => trans('admin::app.datagrid.status'),
'type' => 'boolean',
'searchable' => true,

View File

@ -26,6 +26,7 @@ class LocalesDataGrid extends DataGrid
{
$this->addColumn([
'index' => 'id',
'identifier' => 'id',
'label' => trans('admin::app.datagrid.id'),
'type' => 'number',
'searchable' => false,
@ -35,6 +36,7 @@ class LocalesDataGrid extends DataGrid
$this->addColumn([
'index' => 'code',
'identifier' => 'code',
'label' => trans('admin::app.datagrid.code'),
'type' => 'string',
'searchable' => true,
@ -44,6 +46,7 @@ class LocalesDataGrid extends DataGrid
$this->addColumn([
'index' => 'name',
'identifier' => 'name',
'label' => trans('admin::app.datagrid.name'),
'type' => 'string',
'searchable' => true,

View File

@ -26,6 +26,7 @@ class NewsLetterDataGrid extends DataGrid
{
$this->addColumn([
'index' => 'id',
'identifier' => 'id',
'label' => trans('admin::app.datagrid.id'),
'type' => 'number',
'searchable' => false,
@ -35,6 +36,7 @@ class NewsLetterDataGrid extends DataGrid
$this->addColumn([
'index' => 'is_subscribed',
'identifier' => 'is_subscribed',
'label' => trans('admin::app.datagrid.subscribed'),
'type' => 'string',
'searchable' => true,
@ -50,6 +52,7 @@ class NewsLetterDataGrid extends DataGrid
$this->addColumn([
'index' => 'email',
'identifier' => 'email',
'label' => trans('admin::app.datagrid.email'),
'type' => 'string',
'searchable' => true,

View File

@ -26,6 +26,7 @@ class OrderDataGrid extends DataGrid
{
$this->addColumn([
'index' => 'id',
'identifier' => 'id',
'label' => trans('admin::app.datagrid.id'),
'type' => 'number',
'searchable' => false,
@ -35,6 +36,7 @@ class OrderDataGrid extends DataGrid
$this->addColumn([
'index' => 'base_grand_total',
'identifier' => 'base_grand_total',
'label' => trans('admin::app.datagrid.base-total'),
'type' => 'string',
'searchable' => true,
@ -47,6 +49,7 @@ class OrderDataGrid extends DataGrid
$this->addColumn([
'index' => 'grand_total',
'identifier' => 'grand_total',
'label' => trans('admin::app.datagrid.grand-total'),
'type' => 'string',
'searchable' => true,
@ -59,6 +62,7 @@ class OrderDataGrid extends DataGrid
$this->addColumn([
'index' => 'created_at',
'identifier' => 'created_at',
'label' => trans('admin::app.datagrid.order-date'),
'type' => 'string',
'sortable' => true,
@ -68,6 +72,7 @@ class OrderDataGrid extends DataGrid
$this->addColumn([
'index' => 'channel_name',
'identifier' => 'channel_name',
'label' => trans('admin::app.datagrid.channel-name'),
'type' => 'string',
'sortable' => true,
@ -77,6 +82,7 @@ class OrderDataGrid extends DataGrid
$this->addColumn([
'index' => 'status',
'identifier' => 'status',
'label' => trans('admin::app.datagrid.status'),
'type' => 'string',
'sortable' => true,
@ -103,6 +109,7 @@ class OrderDataGrid extends DataGrid
$this->addColumn([
'index' => 'full_name',
'identifier' => 'full_name',
'label' => trans('admin::app.datagrid.billed-to'),
'type' => 'string',
'searchable' => false,

View File

@ -26,6 +26,7 @@ class OrderInvoicesDataGrid extends DataGrid
{
$this->addColumn([
'index' => 'id',
'identifier' => 'id',
'label' => trans('admin::app.datagrid.id'),
'type' => 'number',
'searchable' => false,
@ -35,6 +36,7 @@ class OrderInvoicesDataGrid extends DataGrid
$this->addColumn([
'index' => 'order_id',
'identifier' => 'order_id',
'label' => trans('admin::app.datagrid.order-id'),
'type' => 'number',
'searchable' => false,
@ -44,6 +46,7 @@ class OrderInvoicesDataGrid extends DataGrid
$this->addColumn([
'index' => 'grand_total',
'identifier' => 'grand_total',
'label' => trans('admin::app.datagrid.grand-total'),
'type' => 'string',
'searchable' => true,
@ -53,6 +56,7 @@ class OrderInvoicesDataGrid extends DataGrid
$this->addColumn([
'index' => 'created_at',
'identifier' => 'created_at',
'label' => trans('admin::app.datagrid.invoice-date'),
'type' => 'datetime',
'searchable' => true,

View File

@ -13,11 +13,11 @@ use DB;
*/
class OrderShipmentsDataGrid extends DataGrid
{
protected $index = 'shipment_id';
protected $index = 'id';
public function prepareQueryBuilder()
{
$queryBuilder = DB::table('shipments as ship')->select('ship.id as shipment_id', 'ship.order_id as shipment_order_id', 'ship.total_qty as shipment_total_qty', 'is.name as inventory_source_name', 'ors.created_at as orderdate', 'ship.created_at as shipment_created_at')->addSelect(DB::raw('CONCAT(ors.customer_first_name, " ", ors.customer_last_name) as custname'))->leftJoin('orders as ors', 'ship.order_id', '=', 'ors.id')->leftJoin('inventory_sources as is', 'ship.inventory_source_id', '=', 'is.id');
$queryBuilder = DB::table('shipments as ship')->select('ship.id', 'ship.order_id', 'ship.total_qty', 'is.name', 'ors.created_at', 'ship.created_at')->addSelect(DB::raw('CONCAT(ors.customer_first_name, " ", ors.customer_last_name) as custname'))->leftJoin('orders as ors', 'ship.order_id', '=', 'ors.id')->leftJoin('inventory_sources as is', 'ship.inventory_source_id', '=', 'is.id');
$this->setQueryBuilder($queryBuilder);
}
@ -25,7 +25,8 @@ class OrderShipmentsDataGrid extends DataGrid
public function addColumns()
{
$this->addColumn([
'index' => 'shipment_id',
'index' => 'ship.id',
'identifier' => 'shipment_id',
'label' => trans('admin::app.datagrid.id'),
'type' => 'number',
'searchable' => false,
@ -34,7 +35,8 @@ class OrderShipmentsDataGrid extends DataGrid
]);
$this->addColumn([
'index' => 'shipment_order_id',
'index' => 'ship.order_id',
'identifier' => 'shipment_order_id',
'label' => trans('admin::app.datagrid.order-id'),
'type' => 'number',
'searchable' => false,
@ -43,7 +45,8 @@ class OrderShipmentsDataGrid extends DataGrid
]);
$this->addColumn([
'index' => 'shipment_total_qty',
'index' => 'ship.total_qty',
'identifier' => 'shipment_total_qty',
'label' => trans('admin::app.datagrid.total-qty'),
'type' => 'number',
'searchable' => true,
@ -52,7 +55,8 @@ class OrderShipmentsDataGrid extends DataGrid
]);
$this->addColumn([
'index' => 'inventory_source_name',
'index' => 'is.name',
'identifier' => 'inventory_source_name',
'label' => trans('admin::app.datagrid.inventory-source'),
'type' => 'string',
'searchable' => true,
@ -61,7 +65,8 @@ class OrderShipmentsDataGrid extends DataGrid
]);
$this->addColumn([
'index' => 'orderdate',
'index' => 'ors.created_at',
'identifier' => 'orderdate',
'label' => trans('admin::app.datagrid.order-date'),
'type' => 'datetime',
'sortable' => true,
@ -70,7 +75,8 @@ class OrderShipmentsDataGrid extends DataGrid
]);
$this->addColumn([
'index' => 'shipment_created_at',
'index' => 'ship.created_at',
'identifier' => 'shipment_created_at',
'label' => trans('admin::app.datagrid.shipment-date'),
'type' => 'datetime',
'sortable' => true,
@ -80,6 +86,7 @@ class OrderShipmentsDataGrid extends DataGrid
$this->addColumn([
'index' => 'custname',
'identifier' => 'custname',
'label' => trans('admin::app.datagrid.shipment-to'),
'type' => 'string',
'sortable' => true,

View File

@ -17,7 +17,7 @@ class ProductDataGrid extends DataGrid
public function prepareQueryBuilder()
{
$queryBuilder = DB::table('products_grid')->addSelect('products_grid.product_id as product_id', 'products_grid.sku as product_sku', 'products_grid.name as product_name', 'products.type as product_type', 'products_grid.status as product_status', 'products_grid.price as product_price', 'products_grid.quantity as product_quantity')->leftJoin('products', 'products_grid.product_id', '=', 'products.id');
$queryBuilder = DB::table('products_grid as pg')->addSelect('pg.product_id', 'pg.sku', 'pg.name', 'pr.type', 'pg.status', 'pg.price', 'pg.quantity')->leftJoin('products as pr', 'pg.product_id', '=', 'pr.id');
$this->setQueryBuilder($queryBuilder);
}
@ -25,7 +25,8 @@ class ProductDataGrid extends DataGrid
public function addColumns()
{
$this->addColumn([
'index' => 'product_id',
'index' => 'pg.product_id',
'identifier' => 'product_id',
'label' => trans('admin::app.datagrid.id'),
'type' => 'number',
'searchable' => false,
@ -34,7 +35,8 @@ class ProductDataGrid extends DataGrid
]);
$this->addColumn([
'index' => 'product_sku',
'index' => 'pg.sku',
'identifier' => 'product_sku',
'label' => trans('admin::app.datagrid.sku'),
'type' => 'string',
'searchable' => true,
@ -43,7 +45,8 @@ class ProductDataGrid extends DataGrid
]);
$this->addColumn([
'index' => 'product_name',
'index' => 'pg.name',
'identifier' => 'product_name',
'label' => trans('admin::app.datagrid.name'),
'type' => 'string',
'searchable' => true,
@ -52,7 +55,8 @@ class ProductDataGrid extends DataGrid
]);
$this->addColumn([
'index' => 'product_type',
'index' => 'pr.type',
'identifier' => 'product_type',
'label' => trans('admin::app.datagrid.type'),
'type' => 'string',
'sortable' => true,
@ -61,7 +65,8 @@ class ProductDataGrid extends DataGrid
]);
$this->addColumn([
'index' => 'product_status',
'index' => 'pg.status',
'identifier' => 'product_status',
'label' => trans('admin::app.datagrid.status'),
'type' => 'boolean',
'sortable' => true,
@ -76,7 +81,8 @@ class ProductDataGrid extends DataGrid
]);
$this->addColumn([
'index' => 'product_price',
'index' => 'pg.price',
'identifier' => 'product_price',
'label' => trans('admin::app.datagrid.price'),
'type' => 'number',
'sortable' => true,
@ -88,7 +94,8 @@ class ProductDataGrid extends DataGrid
]);
$this->addColumn([
'index' => 'product_quantity',
'index' => 'pg.quantity',
'identifier' => 'product_quantity',
'label' => trans('admin::app.datagrid.qty'),
'type' => 'number',
'sortable' => true,

View File

@ -26,6 +26,7 @@ class RolesDataGrid extends DataGrid
{
$this->addColumn([
'index' => 'id',
'identifier' => 'id',
'label' => trans('admin::app.datagrid.id'),
'type' => 'number',
'searchable' => false,
@ -35,6 +36,7 @@ class RolesDataGrid extends DataGrid
$this->addColumn([
'index' => 'name',
'identifier' => 'name',
'label' => trans('admin::app.datagrid.name'),
'type' => 'string',
'searchable' => true,
@ -44,6 +46,7 @@ class RolesDataGrid extends DataGrid
$this->addColumn([
'index' => 'permission_type',
'identifier' => 'permission_type',
'label' => trans('admin::app.datagrid.permission-type'),
'type' => 'string',
'searchable' => true,

View File

@ -13,11 +13,11 @@ use DB;
*/
class SliderDataGrid extends DataGrid
{
protected $index = 'slider_id';
protected $index = 'id';
public function prepareQueryBuilder()
{
$queryBuilder = DB::table('sliders as sl')->addSelect('sl.id as slider_id', 'sl.title as slider_title', 'ch.name as channel_name')->leftJoin('channels as ch', 'sl.channel_id', '=', 'ch.id');
$queryBuilder = DB::table('sliders as sl')->addSelect('sl.id', 'sl.title', 'ch.name')->leftJoin('channels as ch', 'sl.channel_id', '=', 'ch.id');
$this->setQueryBuilder($queryBuilder);
}
@ -25,7 +25,8 @@ class SliderDataGrid extends DataGrid
public function addColumns()
{
$this->addColumn([
'index' => 'slider_id',
'index' => 'sl.id',
'identifier' => 'slider_id',
'label' => trans('admin::app.datagrid.id'),
'type' => 'number',
'searchable' => false,
@ -34,7 +35,8 @@ class SliderDataGrid extends DataGrid
]);
$this->addColumn([
'index' => 'slider_title',
'index' => 'sl.title',
'identifier' => 'slider_title',
'label' => trans('admin::app.datagrid.title'),
'type' => 'string',
'searchable' => true,
@ -43,7 +45,8 @@ class SliderDataGrid extends DataGrid
]);
$this->addColumn([
'index' => 'channel_name',
'index' => 'ch.name',
'identifier' => 'channel_name',
'label' => trans('admin::app.datagrid.channel-name'),
'type' => 'string',
'searchable' => true,

View File

@ -26,6 +26,7 @@ class TaxCategoryDataGrid extends DataGrid
{
$this->addColumn([
'index' => 'id',
'identifier' => 'id',
'label' => trans('admin::app.datagrid.id'),
'type' => 'number',
'searchable' => false,
@ -35,6 +36,7 @@ class TaxCategoryDataGrid extends DataGrid
$this->addColumn([
'index' => 'name',
'identifier' => 'name',
'label' => trans('admin::app.datagrid.name'),
'type' => 'string',
'searchable' => true,
@ -44,6 +46,7 @@ class TaxCategoryDataGrid extends DataGrid
$this->addColumn([
'index' => 'code',
'identifier' => 'code',
'label' => trans('admin::app.datagrid.code'),
'type' => 'string',
'searchable' => true,

View File

@ -26,6 +26,7 @@ class TaxRateDataGrid extends DataGrid
{
$this->addColumn([
'index' => 'id',
'identifier' => 'id',
'label' => trans('admin::app.datagrid.id'),
'type' => 'number',
'searchable' => false,
@ -35,6 +36,7 @@ class TaxRateDataGrid extends DataGrid
$this->addColumn([
'index' => 'identifier',
'identifier' => 'identifier',
'label' => trans('admin::app.datagrid.identifier'),
'type' => 'string',
'searchable' => true,
@ -44,6 +46,7 @@ class TaxRateDataGrid extends DataGrid
$this->addColumn([
'index' => 'state',
'identifier' => 'state',
'label' => trans('admin::app.datagrid.state'),
'type' => 'string',
'searchable' => true,
@ -53,6 +56,7 @@ class TaxRateDataGrid extends DataGrid
$this->addColumn([
'index' => 'country',
'identifier' => 'country',
'label' => trans('admin::app.datagrid.country'),
'type' => 'string',
'searchable' => true,
@ -62,6 +66,7 @@ class TaxRateDataGrid extends DataGrid
$this->addColumn([
'index' => 'tax_rate',
'identifier' => 'tax_rate',
'label' => trans('admin::app.datagrid.tax-rate'),
'type' => 'string',
'searchable' => true,

View File

@ -13,11 +13,11 @@ use DB;
*/
class UserDataGrid extends DataGrid
{
protected $index = 'user_id';
protected $index = 'id';
public function prepareQueryBuilder()
{
$queryBuilder = DB::table('admins as u')->addSelect('u.id as user_id', 'u.name as user_name', 'u.status as user_status', 'u.email as user_email', 'ro.name as role_name')->leftJoin('roles as ro', 'u.role_id', '=', 'ro.id');
$queryBuilder = DB::table('admins as u')->addSelect('u.id', 'u.name', 'u.status', 'u.email', 'ro.name')->leftJoin('roles as ro', 'u.role_id', '=', 'ro.id');
$this->setQueryBuilder($queryBuilder);
}
@ -25,7 +25,8 @@ class UserDataGrid extends DataGrid
public function addColumns()
{
$this->addColumn([
'index' => 'user_id',
'index' => 'u.id',
'identifier' => 'user_id',
'label' => trans('admin::app.datagrid.id'),
'type' => 'number',
'searchable' => false,
@ -34,7 +35,8 @@ class UserDataGrid extends DataGrid
]);
$this->addColumn([
'index' => 'user_name',
'index' => 'u.name',
'identifier' => 'user_name',
'label' => trans('admin::app.datagrid.name'),
'type' => 'string',
'searchable' => true,
@ -43,7 +45,8 @@ class UserDataGrid extends DataGrid
]);
$this->addColumn([
'index' => 'user_status',
'index' => 'u.status',
'identifier' => 'user_status',
'label' => trans('admin::app.datagrid.status'),
'type' => 'boolean',
'searchable' => true,
@ -59,13 +62,24 @@ class UserDataGrid extends DataGrid
]);
$this->addColumn([
'index' => 'user_email',
'index' => 'u.email',
'identifier' => 'user_email',
'label' => trans('admin::app.datagrid.email'),
'type' => 'string',
'searchable' => true,
'sortable' => true,
'width' => '100px'
]);
$this->addColumn([
'index' => 'ro.name',
'identifier' => 'role_name',
'label' => trans('admin::app.datagrid.role'),
'type' => 'string',
'searchable' => true,
'sortable' => true,
'width' => '100px'
]);
}
public function prepareActions() {

View File

@ -69,7 +69,7 @@ return [
'sliders' => 'Sliders',
'taxes' => 'Taxes',
'tax-categories' => 'Tax Categories',
'tax-rates' => 'Tax Rates'
'tax-rates' => 'Tax Rates',
],
'dashboard' => [
@ -143,7 +143,8 @@ return [
'identifier' => 'Identifier',
'state' => 'State',
'country' => 'Country',
'tax-rate' => 'Rate'
'tax-rate' => 'Rate',
'role' => 'Role'
],
'account' => [

View File

@ -111,7 +111,7 @@ abstract class DataGrid
public function findColumnType($columnAlias)
{
foreach($this->completeColumnDetails as $column) {
if($column['index'] == $columnAlias) {
if($column['identifier'] == $columnAlias) {
return [$column['type'], $column['index']];
}
}

View File

@ -17,6 +17,8 @@
$columnIndex = explode('.', $column['index']);
$columnIndex = end($columnIndex);
// dd($columnIndex);
@endphp
@if(isset($column['wrapper']))
@ -45,7 +47,7 @@
@endforeach
@else
<tr>
<td colspan="10" style="text-align: center;">{{$norecords}}</td>
<td colspan="10" style="text-align: center;">{{ $norecords }}</td>
</tr>
@endif
</tbody>

View File

@ -35,7 +35,7 @@
<select class="filter-column-select control" v-model="filterColumn" v-on:click="getColumnOrAlias(filterColumn)">
<option selected disabled>Select Column</option>
@foreach($results['columns'] as $column)
<option value="{{ $column['index'] }}">
<option value="{{ $column['identifier'] }}">
{{ $column['label'] }}
</option>
@endforeach
@ -134,6 +134,7 @@
</div>
</div>
</div>
<div class="filter-row-two">
<span class="filter-tag" v-if="filters.length > 0" v-for="filter in filters" style="text-transform: uppercase;">
<span v-if="filter.column == 'sort'">@{{ filter.label }}</span>
@ -196,7 +197,7 @@
@endif
@foreach($results['columns'] as $key => $column)
<th class="grid_head" style="width: {{ $column['width'] }}" v-on:click="sortCollection('{{ $column['index'] }}')">
<th class="grid_head" style="width: {{ $column['width'] }}" v-on:click="sortCollection('{{ $column['identifier'] }}')">
{{ $column['label'] }}
</th>
@endforeach
@ -267,7 +268,7 @@
this.columnOrAlias = columnOrAlias;
for(column in this.columns) {
if (this.columns[column].index == this.columnOrAlias) {
if (this.columns[column].identifier == this.columnOrAlias) {
this.type = this.columns[column].type;
if(this.type == 'string') {
@ -314,7 +315,7 @@
label = '';
for(colIndex in this.columns) {
if(this.columns[colIndex].index == this.columnOrAlias) {
if(this.columns[colIndex].identifier == this.columnOrAlias) {
label = this.columns[colIndex].label;
}
}
@ -334,7 +335,8 @@
label = '';
for(colIndex in this.columns) {
if(this.columns[colIndex].index == this.columnOrAlias) {
if(this.columns[colIndex].identifier == alias) {
matched = 0;
label = this.columns[colIndex].label;
}
}
@ -343,13 +345,7 @@
},
searchCollection(searchValue) {
label = '';
for(colIndex in this.columns) {
if(this.columns[colIndex].index == this.columnOrAlias) {
label = this.columns[colIndex].label;
}
}
label = 'Search';
this.formURL("search", 'all', searchValue, label);
},
@ -601,10 +597,12 @@
obj.val = val;
if(col == "sort") {
// console.log('sort', obj.cond);
label = '';
for(colIndex in this.columns) {
if(this.columns[colIndex].index == obj.cond) {
if(this.columns[colIndex].identifier == obj.cond) {
obj.label = this.columns[colIndex].label;
}
}
@ -614,7 +612,7 @@
obj.label = '';
for(colIndex in this.columns) {
if(this.columns[colIndex].index == obj.column) {
if(this.columns[colIndex].identifier == obj.column) {
obj.label = this.columns[colIndex].label;
}
}