Code Monkey home page Code Monkey logo

doctrine-datatables's Introduction

Hi ๐Ÿ‘‹, I'm Vaibhav

Theoretically illiterate but practically pro, tech agnostic engineer from India.

vaibhavpandeyvpz

  • ๐Ÿ”ญ I'm currently working on tech, obviously
  • ๐ŸŒฑ I'm currently learning how to cope with ugly code
  • ๐Ÿ‘ฏ I'm looking to collaborate on where I could help
  • ๐Ÿค I'm looking for help with escaping earth
  • ๐Ÿ‘จโ€๐Ÿ’ป All of my projects are available at https://github.com/vaibhavpandeyvpz
  • ๐Ÿ“ I regulary write articles on https://blog.vaibhavpandey.com/
  • ๐Ÿ’ฌ Ask me about anything tech
  • ๐Ÿ“ซ You can reach me on [email protected]
  • ๐Ÿ˜„ Pronouns: VPZ
  • โšก Fun fact never went to college

doctrine-datatables's People

Contributors

moosjes avatar vaibhavpandeyvpz avatar

Stargazers

 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

doctrine-datatables's Issues

Allow OR-based search or customize search

I'm currently not sure whats the best way to provide a custom search or at least let the user decide which algorithm to use.

To provide better multi-column search with only a single search box I've modified the filtered query to split the search param by whitespaces and transform the query accordingly.
It would be great to have a parameter to define the default behaviour or allow custom methods.

Current logic is:
WHERE (col1 LIKE "search multiple" OR col2 LIKE "search multiple")

How I implemented it:
WHERE (col1 LIKE "search" OR col2 LIKE "search") AND (col1 LIKE "multiple" OR col2 LIKE "multiple")

Code:

if (array_key_exists('search', $this->requestParams)) {
			$searchValues = explode(' ', $this->requestParams['search']['value']);
			$searchId = 0;
			foreach ($searchValues as $searchValue) {
				$searchId++;
				$searchKey = 'search'.$searchId;
				if ($searchValue = trim($searchValue)) {
					$orX = $query->expr()->orX();
					for ($i = 0; $i < $c; $i++) {
						$column = &$columns[$i];
						if ($column['searchable'] == 'true') {
							if (array_key_exists($column[$this->columnField], $this->columnAliases)) {
								$column[$this->columnField] = $this->columnAliases[$column[$this->columnField]];
							}
							$orX->add($query->expr()->like($column[$this->columnField], ":$searchKey"));
						}
					}
					if ($orX->count() >= 1) {
						$query->andWhere($orX)
							->setParameter($searchKey, "%{$searchValue}%");
					}
				}
			}
		}

Getting No route found for "GET /regex..."

When I call the route for the api, I only the a 404 error with No route found for "GET /regex..."

My controller:

 /**
     * @Route("/games/api/ssp", name="gamesSSPApi")
     */
    public function indexSSPAction()
    {
        $em = $this->getDoctrine()->getManager();

        $datatables = (new DataTables\Builder())
            ->withIndexColumn('number')
            ->withQueryBuilder(
                $em->createQueryBuilder()
                    ->select('g')
                    ->from(Game::class, 'g'))
            ->withRequestParams($_GET);

        echo json_encode($datatables->getResponse());
    }

When i call it like /games/api/ssp?draw=1 all is fine.

My datatable initialization:

$('#datatable-overview-date-1').DataTable( {
                "processing": true,
                "serverSide": true,
                "ajax": "{{ path('gamesSSPApi') }}",
                "language": {
                    "url": "//cdn.datatables.net/plug-ins/1.10.15/i18n/German.json"
                },
                columnDefs: [
                    { type: 'de_date', targets: 0 }
                ]
            } );

Format output

Is there a way to define formatters?
For example to print HTML formatted cell content?

Thanks

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.