Git Product home page Git Product logo

datatables-bundle's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

datatables-bundle's Issues

ORM Adapter returns null for an attribute

My Entity:

<?php

namespace App\Entity;

use Doctrine\ORM\Mapping as ORM;

/**
 * @ORM\Entity(repositoryClass="App\Repository\CustomerRepository")
 */
class Customer
{
    /**
     * @ORM\Id()
     * @ORM\GeneratedValue()
     * @ORM\Column(type="integer")
     */
    private $id;

    /**
     * @ORM\Column(type="string", length=255)
     */
    private $name;

    /**
     * @ORM\Column(type="datetime")
     */
    private $deactivated;

    public function getId(): ?int
    {
        return $this->id;
    }

    public function getName(): ?string
    {
        return $this->name;
    }

    public function setName(string $name): self
    {
        $this->name = $name;

        return $this;
    }

    public function getDeactivated(): ?\DateTime
    {
        return $this->deactivated;
    }

    public function isDeactivated(): bool
    {
        return $this->deactivated !== null;
    }

    public function setDeactivated(\DateTime $deactivated): self
    {
        $this->deactivated = $deactivated;

        return $this;
    }
}

The datatable (php) Part:

$table = $this->createDataTable()
            ->add('name', TextColumn::class, [
                'className' => 'dt-body-center',
                'label' => $translator->trans('customerOverview.table.header.name')
            ])
            ->add('buttons', TwigColumn::class, [
                'className' => 'dt-body-center',
                'template' => 'customer/table/options.html.twig',
                'label' => $translator->trans('customerOverview.table.header.options')
            ])
            ->createAdapter(ORMAdapter::class, [
                'entity' => Customer::class,
            ])
            ->handleRequest($request);

I tried to show different buttons if the customer is (de)actived, but i always saw the deactived button so i used {{ dump(row) }} in the twig template and got the following output

Customer {#615 โ–ผ
  -id: 1
  -name: "test123"
  -deactivated: null
}

But the Customer has a date in the database!
Also if i fetch the User in Symfony the deativated attribute of the customer is filled!

Edit: Another quick question... is it possible to automaticlly translate the labels ?

Add namespace and callbacks to statefullness

  • Multiple tables on the same page should be namespaced to avoid collisions
  • It should be easily possible to plug in to reading/writing state data for example for external filter forms

ORMAdapter with repositories

Hello,

Is there any example on how I can make this work with ORMAdapter when using EntityRepository?
Ex.
Controller

$jobs = $this->jobRepository->findByManager($currentUser);
$table = $dataTable->create()
            ->add('id', TextColumn::class)
            ->createAdapter(ORMAdapter::class, [
                  'entity' => Job::class,
                  'query' => $jobs
            ])
            ->handleRequest($request);

JobRepository

public function findByManager(User $manager)
    {
        $queryBuilder = $this->createQueryBuilder('j');
        $queryBuilder->select('j')
            (...joins and where...)
            ->getQuery();
        return $queryBuilder->getQuery()->getResult();
    }

This with ->getResult() won't obviously work, I tried returning only query but nothing. I did succeeded with using ArrayAdapter and using getArrayResult to return but I need objects as I call some additional checks on models.

Thanks

Documentation syntax error - Customizing criteria

Under Customizing criteria

$table->createAdapter(ORMAdapter::class, [
    'entity' => Employee::class,
    'criteria' => [
        function () {
            return Criteria::create()->andWhere(new Comparison('c.name', Comparison::CONTAINS, 'ny 2'));
        },
        new SearchCriteriaProvider(),
    },
]);

Should be

$table->createAdapter(ORMAdapter::class, [
    'entity' => Employee::class,
    'criteria' => [
        function () {
            return Criteria::create()->andWhere(new Comparison('c.name', Comparison::CONTAINS, 'ny 2'));
        },
        new SearchCriteriaProvider(),
    ],
]);

Note the bracket under SearchCriteriaProvider() - ]
(sorry for the formatting for some reason the "code" block doesn't work as expected)

Seperate query from table builder

Hello!

What would be the best way to seperate query code from the datatable builder code itself?
My queries can get long and I'd like to keep my datatable type class as clean as possible.

class MyTableType implements DataTableTypeInterface
{
    public function configure(DataTable $dataTable, array $options)
    {
        $request = $options['request'];

        $dataTable
            ->add('id',
                NumberColumn::class,
                array(
                    'label' => 'ID',
                    'globalSearchable' => false
                )
            )

... Some more columns ...

->createAdapter(ORMAdapter::class,
                array(
                    'entity' => MyEntity::class,
                    'query' => function (QueryBuilder $builder) use ($request)
                    { //Long query I'd prefer to get from somewhere else }
                )
            )
        ;
    }
}

Do I need to create a class that implements QueryBuilderProcessorInterface for each entity I'd build my tables for?

Anytime I try and use 'query' or 'criteria' I get a 500 error

Symfony: 4.1
Omines Datatables: ^0.2.0
Using Doctrine ORM

Each time I try and add a query or criteria to my code, with the example below, I get 500 errors and these messages in the console.

POST http://127.0.0.1:8012/users
DataTables request failed:
Uncaught (in promise) error

Two examples of the code execution are:

        $table = $this->createDataTable()
            ->add('code', TextColumn::class, ['label' => 'Code'])
            ->add('email', TextColumn::class, ['label' => 'Email'])
            ->add('firstName', TextColumn::class, ['label' => 'First name'])
            ->add('lastName', TextColumn::class, ['label' => 'Last name'])
            ->add('createdAt', DateTimeColumn::class, ['label' => 'Date created', 'format' => 'H:i d-m-Y'])
            ->add('', TextColumn::class, ['label' => 'Loyalty Card', 'render' => function ($value, $context) {}])
            ->add('platform', TextColumn::class, ['label' => 'Platform'])
            ->add('appVersion', TextColumn::class, ['label' => 'Version'])
            ->add('id', TextColumn::class, ['label' => 'Actions', 'render' => function ($value, $context) {return sprintf('<a class="btn btn-mini" href="/users/%s/edit">Edit</a><a class="btn btn-mini" href="/users/%s/delete">Delete</a>', $value, $value);}, 'raw' => true])
            ->createAdapter(ORMAdapter::class, [
                'entity' => Users::class,
                'criteria' => [
                    function () {
                        return Criteria::create()->andWhere(new Comparison('u.roles', Comparison::CONTAINS, 'ADMIN'));
                    },
                    new SearchCriteriaProvider(),
                ],
            ])
            ->handleRequest($request);

And

    $table = $this->createDataTable()
        ->add('code', TextColumn::class, ['label' => 'Code'])
        ->add('email', TextColumn::class, ['label' => 'Email'])
        ->add('firstName', TextColumn::class, ['label' => 'First name'])
        ->add('lastName', TextColumn::class, ['label' => 'Last name'])
        ->add('createdAt', DateTimeColumn::class, ['label' => 'Date created', 'format' => 'H:i d-m-Y'])
        ->add('', TextColumn::class, ['label' => 'Loyalty Card', 'render' => function ($value, $context) {}])
        ->add('platform', TextColumn::class, ['label' => 'Platform'])
        ->add('appVersion', TextColumn::class, ['label' => 'Version'])
        ->add('id', TextColumn::class, ['label' => 'Actions', 'render' => function ($value, $context) {return sprintf('<a class="btn btn-mini" href="/users/%s/edit">Edit</a><a class="btn btn-mini" href="/users/%s/delete">Delete</a>', $value, $value);}, 'raw' => true])
        ->createAdapter(ORMAdapter::class, [
            'entity' => Users::class,
            'query' => function (QueryBuilder $builder) {
                $builder
                    ->select('u')
                    ->from(Users::class, 'u')
                    ->where('u.roles NOT LIKE :roles')
                    ->setParameter('roles', '%"ROLE_ADMIN"%')
                ;
            },
        ])
        ->handleRequest($request);

I cannot get anything useful from the console or Symfony error logs when running in debug mode, so any thoughts would be a great help. If I have also missed anything useful please let me know.

Displaying search field

Hello everyone. Im new to omines/datatables-bundle and I have problem displaying search.

I was studying your documentation and was not able to get it working.
Ive created a table like this

$table = $dataTable->create()
          ->add('street', TextColumn::class, ["label" => "Street", "searchable" => true, "globalSearchable" => true])
          ->add('houseNumber', TextColumn::class, ["label" => "House number", "searchable" => true])
          ->add('postal', TextColumn::class, ["label" => "Postal Code", "searchable" => true])
          ->add('city', TextColumn::class, ["label" => "City", "searchable" => true])
          ->add('country', TextColumn::class, ["label" => "Country", "searchable" => true])
          ->createAdapter(ORMAdapter::class, [
            'entity' => CustomAddress::class,
          ])
          ->handleRequest($request);

        if ($table->isCallback()) {
            return $table->getResponse();
        }

        return $this->render('sales_request/add_custom_address.html.twig', ['datatable' => $table]);

Also, in my twig template

<div id="addresses">Loading...</div>
    <script src="{{ asset('bundles/datatables/js/datatables.js') }}"></script>
    <script>
        $(function() {
            $('#addresses').initDataTables({{ datatable_settings(datatable) }}, { searching: true });
        });
    </script>

The datatable works fine, sorting is working etc, but I dont see the search input field.How should I configure it to display it?

Can't search by datetime field

This is the code of my action:

public function index(Request $request, CarRepository $carRepository, DataTableFactory $dataTableFactory)
    {
        $table = $dataTableFactory->create()
            ->add('id', NumberColumn::class, ["orderable" => true, "searchable" => true])
            ->add('carBrand', TextColumn::class, ["field" => "brand.name", "orderable" => true, "label" => "Marca del Carro", "searchable" => true])
            ->add('model', TextColumn::class, ["field" => "car.model", "orderable" => true, "label" => "Modelo del Carro", "searchable" => true])
            ->add("filledAt", DateTimeColumn::class, ["format" => "Y-m-d H:i:s", "searchable" => true, "orderable" => true])
            ->add("fuelFilled", NumberColumn::class, ["render" => "%s L", "searchable" => true])
            ->add("price", NumberColumn::class, ["render" => "%s cuc", "searchable" => true])
            ->add("formerRead", NumberColumn::class, ["searchable" => true])
            ->add("currentRead", NumberColumn::class, ["searchable" => true])
            ->add("mileage", NumberColumn::class, ["searchable" => true])
            ->add('actions', TwigColumn::class, [
                'className' => 'buttons',
                'template' => 'frontend/supervisor/carfill/table-buttons.html.twig',
            ])
            ->addOrderBy('filledAt', DataTable::SORT_DESCENDING)
            ->createAdapter(ORMAdapter::class, [
                "entity" => CarFuelFillRecord::class,
                "query" => function(QueryBuilder $builder){
                    $builder
                        ->from("App:CarFuelFillRecord", "cffr")
                        ->select("cffr, car, brand")
                        ->leftJoin("cffr.car", "car")
                        ->leftJoin("car.brand", "brand")
                    ;
                }
            ])
            ->handleRequest($request);

        if ($table->isCallback()) {
            return $table->getResponse();
        }

        return $this->render('frontend/supervisor/carfill/index.html.twig', [
            'datatable' => $table,
            "cars" => $carRepository->findAll()
        ]);
    }

This is the code of my template
$(function() { $('#carFuelFillRecords').initDataTables({{ datatable_settings(datatable) }},{searching: true}); });
The datatable renders well, and it let me search by all the fields except by the only DateTimeColumn field.

What am i doing wrong? Thanks a lot in advance

Query parameter URL

Hello!

Is there a possibility to pass query parameters along with datatables request?
Lets say I am on mypage.com/users/?active=1 because I want to filter only active users. Datatables unfortunately sends request from mypage.com/users so my controller has no idea about my filter parameters. Is there anything I can do?

My code looks something like this:

`public function indexAction(Request $request)

    {

$activeState    = $request->query->get('state', 0);
$table = $this->createDataTableFromType(UsersTableType::class)
            ->createAdapter(ORMAdapter::class, [
                'entity' => User::class,
                'query' => function (QueryBuilder $builder) use ($activeState) {
                    $builder
                        ->select('u')
                        ->from(User::class, 'u');
                            ->where('u.isActive = :ua')
                            ->setParameter('ua', $activeState);
                }
            ])
            ->handleRequest($request);
}`

I will be grateful for any help.

Install doctrine/doctrine-bundle to use the ORMAdapter

Hi guy,

Thank you for your great work on this bundle, it's looking awesome.

Actually i'm trying this just for me and i have the errror "Install doctrine/doctrine-bundle to use the ORMAdapter". And i don't understand why.

doctrine/doctrine-bundle is already in my appkernel.php, so i don't understand why it's not working.

You can show my code below.

AppKernel.php

$bundles = [ new Symfony\Bundle\FrameworkBundle\FrameworkBundle(), new Symfony\Bundle\SecurityBundle\SecurityBundle(), new Symfony\Bundle\TwigBundle\TwigBundle(), new \Omines\DataTablesBundle\DataTablesBundle(), new Symfony\Bundle\MonologBundle\MonologBundle(), new Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle(), new Doctrine\Bundle\DoctrineBundle\DoctrineBundle(), new Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(), new AppBundle\AppBundle(), ];

and here my controller where i try to create a dataTable

`public function indexAction(Request $request)
{
$table = new DataTable();
$table
->add('firstname', TextColumn::class)
->add('lastname', TextColumn::class)
->add('email', TextColumn::class)
->add('phone', TextColumn::class)
->add('age', TextColumn::class)
->createAdapter(ORMAdapter::class, [
'entity' => User::class]
);

    $table->handleRequest($request);

    if ($table->isCallback()) {
        return $table->getResponse();
    }

    return $this->render('dataTableIndex.html.twig', ['dataTable'=>$table]);
}`

Best regards

Wrong namespaces on Tests directory

Hi,

Tests Entities are using wrong namespace, causing IDEs to fail autocompletion.
Should be
namespace Omines\DataTablesBundle\Fixtures\AppBundle\Entity;

Adapter criteria not working as documented?

It could be just me doing something wrong but taking the "Customizing criteria" code snippet from the documentation doesn't produce anything in the end SQL query (has no effect and throws no error no matter what you type as criteria), I've tried with simple closure and as documented with no effect:

$table->createAdapter(ORMAdapter::class, [
    'entity' => Employee::class,
    'criteria' => [
        function () {
            return Criteria::create()->andWhere(new Comparison('c.name', Comparison::CONTAINS, 'ny 2'));
        },
        new SearchCriteriaProvider(),
    },
]);

What works for me is:

$this->createDataTable()
    ->createAdapter(ORMAdapter::class, [
        'entity' => SomeEntity::class,
        'criteria' => function(Doctrine\ORM\QueryBuilder $builder) use ($filters)
        {

            $criteria = Doctrine\Common\Collections\Criteria::create();

            $criteria->andWhere(
                $criteria::expr()->eq("x.y", $filters['x'])
            );

            //add composed criteria
            $builder->addCriteria($criteria);
        }
]);

But that's not the same, also "Note that implementing your own criteria overrides the default, meaning searching and sorting will no longer work automatically." doesn't seem to be true as well (at least in the above configuration) since sorting is still working with the added criteria.

omines/datatables-bundle ^0.2.1 / Symfony 4.2.2 / PHP 7.2.14

Is there something I am missing here ๐Ÿ˜ƒ

BoolColumn

Hi
Another question :)
When using the BoolColumn it is possible to give it a true or false value.
My question is now if I could give him an HTML code to display (FontAwesome as example) to get something like a checkmark ?

Question or Issue? using variable in query

Hi, again me...
This time I'm not sure if it's an issue or Question
The point is the following is working:
->createAdapter(ORMAdapter::class, [
'entity' => Systems::class,
'query' => function (QueryBuilder $builder) {
$builder
->select('systems')
->from(Systems::class, 'systems')
->orderBy('systems.level', 'ASC')
->addorderBy('systems.label', 'ASC')
->andwhere('systems.territory = :SearchTerritory')
->setParameter('SearchTerritory', 'Independent');
},
But when I replace 'Independent' with a variable like $territory which is given globally to my controller this doesn't work. Is there a restriction from you component here because I searched now for a while and everywhere it's marked that this should work with the querybuider...
Here I'm just getting plenty jquery errors :(
Looking at those I see Notice: Undefined variable: territory but dumping the variable before I create the table is working, so the variable is correctly set.
I suppose somehow the variable is not send over to the table but why I just can say ????

Extract Javascript to an asset

Currently we only really support using the datatable or datatable_js Twig functions to generate the required clientside code. We should move this to a separate JS file and reduce it to minimalist calls in the main template.

Integration would likely rock most if we could do something like:

<div id="myFunkyTable">{{ datatable_html(myTable) }}</div>
<script>
datatables.initTable({{ datatable_options(myTable) }}, {
  ...native DataTables options...
});
</script>

Implement Symfony 4 compatibility

Currently Symfony 4 is explicitly disallowed via composer.json. We need to set up functional tests with Symfony 4 to iron out any incompatibilities.

Symfony 3.2

Hi.
I would like to use your bundle, but is really necessary to upgrade Symfony to 3.3?

Access to entity fields in table builder

Hi!
What is the best way to acess all of the entity fields in my table builder?
I've created seperate file implementing DataTableTypeInterface where I build my table I want to display using ORMAdapter. There problem is when using render field option. The $context variable holds only fields I have added to the table, the rest are set to null.
Should I add a column with the field I want to access and set its visibility to false? Or is there a better way?

For example, here I would not have access to username field of my user entity.

class UsersTableType implements DataTableTypeInterface
{
    public function configure(DataTable $dataTable, array $options)
    {
        $dataTable
            ->add('id',
                TextColumn::class,
                array(
                    'label' => 'ID',
                    'render' => function ($value, $context) {
			return $context->getUserName(); }
                )
            )
	->createAdapter(ORMAdapter::class, [
                'entity' => Coupon::class
	]
    }
}

Add Another options

When i try to add deferRender options, an error occurs. Even though deferRender feature available in datatables documentation

The option "deferRender" does not exist. Defined options are: "autoWidth", "displayStart", "dom", "fixedHeader", "jQueryUI", "lengthChange", "lengthMenu", "order", "orderCellsTop", "ordering", "pageLength", "paging", "pagingType", "processing", "search", "searchDelay", "searching", "serverSide", "stateSave".

No result displayed for hydrationMode = Query::HYDRATE_ARRAY with ORMAdapter

I have the message "Notice: Undefined offset: 0" and no result displayed with :

class FooTableType implements DataTableTypeInterface
{
    public function configure(DataTable $dataTable, array $options)
    {
        $dataTable
            ->add('bar', TextColumn::class)
            ->add('baz', TextColumn::class)
            ->createAdapter(ORMAdapter::class, ['hydrate' => Query::HYDRATE_ARRAY, 'entity' => Foo::class]);
    }

Dumped Contents

In ORMAdapter.php line 197:
array:1 [
  0 => array:3 [>]
]

In ORMAdapter.php line 197:
array:1 [
  1 => array:3 [>]
]

In ORMAdapter.php line 197:
array:1 [
  2 => array:3 [>]
]

In ORMAdapter.php line 197:
array:1 [
  3 => array:3 [>]
]

(ErrorException) Notice: Undefined index

Hello, all.
I am always getting this notice while trying to get some data from associated tables via ORMAdapter. Exception page is pointing at line 266 from \ORMAdapter.php. I know there is something wrong with my field name but i don't know how to fix it. Need some enlightenment!

(ErrorException) Notice: Undefined index: type_id

Here is my controller sample:

$table = $this->createDataTable()->add('type_title', TextColumn::class, ['field' => 'type_id.title', 'label' => 'TESTING']);

$table->createAdapter(ORMAdapter::class, [
		'entity' => ShipInfo::class,
		'query' => function (QueryBuilder $builder) {
			$builder
				->select('s')
				->from(ShipInfo::class, 's')
				->orderBy('s.name', 'ASC')
				;
		},
])->handleRequest($request);

App\Entity\ShipInfo

/**
* @ORM\ManyToOne(targetEntity="App\Entity\ShipTypes", inversedBy="ships")
* @ORM\JoinColumn(name="type_id", referencedColumnName="id", nullable=false)
 */
 private $type_id;

public function getTypeId(): ?ShipTypes
    {
        return $this->type_id;
    }

// ...
private $name;

App\Entity\ShipTypes

public function __construct()
{
     $this->ships = new ArrayCollection();
}
/**
 * @ORM\OneToMany(targetEntity="App\Entity\ShipInfo", mappedBy="type_id")
 */
 private $ships;

/**
 * @return Collection|ShipInfo[]
 */
 public function getShips(): Collection
 {
     return $this->ships;
 }
// ...
private $title;

I've tried both "typeId.title" and "type_id.title" by the way.
Any help would be appreciated.

ADDITION

$table = $this->createDataTable()->add('type_id, TextColumn::class');
$table->createAdapter(
//...
)

Returning blank row. It is acting like "type_id" column is empty -- which is not.

Delegate default column settings to adapter

Currently the columns have built-in logic to decide whether they are searchable/sortable. This behavior is not acceptable in all adapters, ie. when using ElasticaAdapter you will now incorrectly see text columns show up as sortable, and numeric columns as searchable, while neither should be default.

How to display array field?

Hi,

I want to know how could I display serialized field - for example roles which are serialized in db for UserEntity. For now I did it by a trick, but there should be some way to do it.

Temporary fix:

public function normalize($value): string
    {
        if (is_array($value)) $value = implode(', ', $value); //added
        $value = (string) $value;

        return $this->isRaw() ? $value : htmlspecialchars($value, ENT_QUOTES | ENT_SUBSTITUTE);
    }

Iterate with fetch join error

First of all thanks for nice approach to the problem.

However I'm kind of stuck at the moment, any chance to shed a light on following exception I'm facing?

Iterate with fetch join in class App\Entity\CategoryTranslation using association translatable not allowed.

This is custom query I use:

->createAdapter(ORMAdapter::class, [
    'entity' => Category::class,
    'query' => function (QueryBuilder $builder) {
        $builder
            ->select('c', 't')
            ->from(Category::class, 'c')
            ->leftJoin('c.translations', 't', Expr\Join::WITH, 't.locale = :locale')
            ->setParameter('locale', $this->locale)
        ;
    },

There is only one translation being shown in the listing at one time - can this be fixed by changing hydration type? I'm fairly new to doctrine as well, is possible to solve this kind of problem at all? I know that iterate has some limits, but maybe I'm missing something obvious.

Also I have a question regarding custom types - is possible to use repositories when creating an adapter?

problem with stateSave: true

Using option stateSave: true , state is saved, but after reload page, 1st page show not related to saved state
I also set persist_state: none in datatables.yml

Thanks

Passing arguments into TextColumn

Hello again.
I want to add 'actions (edit & delete)' column for my table:

$table->add('actions', TextColumn::class, [
		'label' => 'Actions',
		'className' => 'text-right table-actions',
		'render' => '
			<a class="table-action hover-primary" href="/edit/{id}"><i class="ti-pencil"></i></a>
			<a class="table-action hover-danger" href="/delete/{id}"><i class="ti-trash"></i></a>
		'])

As you can see, i need to find a way to define {id} for current row. Is it possible to get this 'id' field from ORMAdapter?

Support inheritance

Hey. The bundle promises to be very good. More comfortable to use than stwe. I have a problem. In the case of ORM inheritance, the field option does not read data - the columns are empty. It also does not throw any exception. Am I doing something wrong, is there really no support? I solved this problem in such a way that I process context in a callback render, but it would be nice if support for inheritance would exist. P.S Sorry for my bad english

`
// ...
@Orm\InheritanceType("JOINED")
abstract class Address {
private $id;
}

// ...
class OrderAddress extends Address {
}

class Order {

@Orm\ManyToOne(targetEntity=OrderAddress::class, cascade={"persist"})
private $address;
}

// ... in Controller
->add('address', TextColumn::class, [
'field' => 'address.id' // not working
])

`

Request $request

I followed all the instruction of the quickstart guide yet, I'm getting an error with the Request request, it doesn't know what it is
`

public function showAction(Request $request)
{
    $table = $this->createDataTable()
        ->add('firstName', TextColumn::class)
        ->add('lastName', TextColumn::class)
        ->createAdapter(ArrayAdapter::class, [
            ['firstName' => 'Donald', 'lastName' => 'Trump'],
            ['firstName' => 'Barack', 'lastName' => 'Obama'],
        ])
        ->handleRequest($request);

    if ($table->isCallback()) {
        return $table->getResponse();
    }

    return $this->render('list.html.twig', ['datatable' => $table]);
}

}`

[Documentation mistake ]

In the documentation online, you specify, for DataTablesTrait, to include in our code
Omines\DataTablesBundle\DataTablesTrait

Instead we should read
Omines\DataTablesBundle\Controller\DataTablesTrait

Thanks.

Issue: Buttons are not appearing when defined in the DOM option

Hi all, I am attempting to include the button options on some of my tables yet when applying the DOM options as per this link: https://omines.github.io/datatables-bundle/#javascript

Details:
Symfony 4.1
Omines DataTable: 0.2.0
PHP: 7.1

I get no buttons appearing on the page, but also no errors.

Sample code from one of the tables:

$('#gimmebrows').initDataTables({{ datatable_settings(datatable) }}, {
                searching: true,
                dom: 'BlTfgitp',
                buttons: ['copy'],
                order: [10, 'desc']
});

It also does not work with the code as per the example in the docs:

dom:'<"html5buttons"B>lTfgitp',
    buttons: [
        'copy',
        { extend: 'pdf', title: 'domains'},
        { extend: 'print' }
 ]

Any insights, or if there is an updated method would be appreciated.

Default ordering? Doctrine ORM Adapter

More of a question than an issue based on the default ordering.

I am trying to simply order an entity table based on a createdAt field, in descending order. I can do this in the query builder but then the ordering takes precedence on all queries. Adding order to the datatables js options only visually sorts it. There is something missing on my server side query that I am just not getting at the moment.

->createAdapter(ORMAdapter::class, [
                'entity' => User::class,
                'query' => function (QueryBuilder $qb) {
                    $qb
                    ->select(['u, 'a'])
                    ->from(User::class, 'u')
                    ->leftJoin('u.defaultAddress', 'a')
                    ->orderBy('u.createdAt', 'DESC') // This forces all queries on the callback to use this
                    ;
                }
            ])

Probably something really simple but appreciate any guidance.

Uncaught TypeError: $(...).initDataTables is not a function

Following the instructions at https://omines.github.io/datatables-bundle/ I have installed with composer, configured the options in my config.yml, added the controller code, passed the object to the template, and added the datatable_settings() twig filter within script tags as instructed (wrapped in a $(function) block. I am getting a jQuery error: $(...).initDataTables is not a function, and i do have all the dependencies in the {% block javascripts %}{% endblock %} (in the correct order). I am not compressing with assetic (or anything else, not that it would be an issue I'm sure). It appears I have followed the instructions exactly, but I'm guessing I am missing something minor, any assistance is appreciated!

Symfony 3.3.*
Datatables 1.10.15
jQuery 3.1.1

Is there an option to add styling to table row?

Hi,

at the beginning thank you for developing this useful plugin. I want to know if there is an option to ### add html class to table row depending on a field from entity class? I was looking in the documentation but I only found that I can addClass directly to the column, but I have to hilight whole row element and would like to avoid adding className to each column.

Thanks!

Question: ManyToOne Relation

Hi
I have 2 tables related to each other with a ManyToOne relation.
I wanted now to display in my datatable the data from the relationship and I thought I would make use of a join or so but that doesn't seem to work.
Taking your example here:
$table->createAdapter(ORMAdapter::class, [
'entity' => Employee::class,
'query' => function (QueryBuilder $builder) {
$builder
->select('e')
->addSelect('c')
->from(Employee::class, 'e')
->leftJoin('e.company', 'c')
;
},
]);
and assuming comapny has a field label I thought I could use than c.label to display the text but that doesn't work. Just getting an error that can't do anything with that field.

Do you have any idea what I could do?
Maybe I'm doing something wrong as I'm very new in dev this could easily be especially as I'm not working daily with that.

Implement client-side tables

Currently every table will be serverside AJAX, which may be overkill or even explicitly undesired in certain cases. By inline invoking the Adapter we should be able to easily implement a full clientside table as well using DataTables.

Using the MongoDB Adaptor

Hi,
Does anyone have any examples of how to implement this with Doctrine MongoDB. The Adaptor seems to need to take a Collection how would I create this and then pass it in? The documentation just shows a string which is obviously incorrect. I've tried passing in for example from the document manager:

$documentManager = $this->container->get('doctrine.odm.mongodb.document_manager');
$collection = $documentManager->getDocumentCollection('AppBundle\Document\Reservation');

table = $this->createDataTable()
            ->add('guest', TextColumn::class)
            ->add('reference', TextColumn::class)
            ->createAdapter(MongoDBAdapter::class, [
                'collection' => $collection,
            ])
            ->handleRequest($request);

But this returns a "LoggableCollection" which fails the options validation, allowing a LoggableCollection then throws a "Projection cannot have a mix of inclusion and exclusion."

I feel I am missing something obvious here / MongoAdaptor isn't finished yet.

If anyone can help that would be great, I love the way this bundle is written and would love to use it.

Search delay

Search delay always send request on first typing making unnecessary search. Search delay should be started after last keyup, when key down again stop

Service "Omines\DataTablesBundle\DataTableFactory" not found

Hello,

i used this getting started https://omines.github.io/datatables-bundle/#datatable-types.
So i installed the composer package, added it to the bundles.php

Omines\DataTablesBundle\DataTablesBundle::class => ['all' => true]

installed datatables with yarn(aka npm) and used the example php code from getting Started.

First off all i get a error from PHP

'UserController' and 'DataTablesTrait' define the same property ($container)

but i think its only a PHPDoc issue...

When i try to load the site i get this error


Service "Omines\DataTablesBundle\DataTableFactory" not found: even though it exists in the app's container, the container inside "App\Controller\UserController" is a smaller service locator that only knows about the "doctrine", "form.factory", "http_kernel", "parameter_bag", "request_stack", "router", "security.authorization_checker", "security.csrf.token_manager", "security.token_storage", "serializer", "session" and "twig" services. Unless you need extra laziness, try using dependency injection instead. Otherwise, you need to declare it using "UserController::getSubscribedServices()".

Support extensions and their configuration

In light of #19: some properties are only valid if certain extensions are loaded in the clientside libraries. We should consider having some kind of extension registration so we can reject using invalid options still.

Finish ArrayAdapter

It currently does not support column-level searches or ordering, and paging does not work correctly when doing a global search (page is taken before filtering instead of after).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.