Code Monkey home page Code Monkey logo

Comments (15)

13ran avatar 13ran commented on July 4, 2024 1

That works. Thanks again for all the help!!

from datatables.

n1crack avatar n1crack commented on July 4, 2024

I'm checking.

from datatables.

n1crack avatar n1crack commented on July 4, 2024

I think I made it on purpose since it is not recommended to use dash in the columns. Using dashes (-) in column names is generally discouraged because many programming languages, databases, and tools interpret the dash as a subtraction operator or other special character.

you can use underscore instead.

from datatables.

13ran avatar 13ran commented on July 4, 2024

If the column name has `` around it, it shouldn't cause any problems. I'd really like to avoid renaming all the columns in my database as it already has millions of rows and selecting as another name causes issues when I try and filter the column

from datatables.

n1crack avatar n1crack commented on July 4, 2024

what about using like this:

$dt->query("SELECT
    `test-test` AS `test_test`
FROM
    `test`");

In this case, you dont have to rename your columns.

from datatables.

13ran avatar 13ran commented on July 4, 2024

Causes issues with filtering as test_test doesnt exist in the database. Unless theres some way I can change the column?

$dt->filter('test_test', function () {
     return $this->column = '`test-test`';
});

That doesn't work but is there a way to do that?

from datatables.

n1crack avatar n1crack commented on July 4, 2024

Not sure whats wrong.. Its working for me as expected.

image

from datatables.

n1crack avatar n1crack commented on July 4, 2024

image

and this is the default filtering

from datatables.

n1crack avatar n1crack commented on July 4, 2024

Can you show me the error you get ? maybe there is another problem ?

from datatables.

13ran avatar 13ran commented on July 4, 2024

Sorry you are correct it does work. My request was just timing out because it was doing a LIKE search.

How do I make it do an exact search? This is the data being sent to the server

columns[9][data]: phone_number
columns[9][name]: 
columns[9][searchable]: true
columns[9][orderable]: true
columns[9][search][value]: ^123456$
columns[9][search][regex]: true

Also is there a way to filter on multiple columns with OR? Say for example the column being searched is phone_number I would like the query to be where phone_number = 'value' or some_other_column = 'value'

from datatables.

n1crack avatar n1crack commented on July 4, 2024

When you type in search input, all columns that has searchable: true are being search with "LIKE" and merged with 'OR'.

Lets say, you need to filter by full text, then you can bypass default filter like :

    $dt->filter('test_test', function () {
        return $this->column->name.' = '. $this->escape($this->searchValue());
    });

from datatables.

13ran avatar 13ran commented on July 4, 2024

Thanks. Now how would I make that filter apply only when searchValue() has a value?

from datatables.

n1crack avatar n1crack commented on July 4, 2024

Ah sorry, here it is:

   $dt->filter('test_test', function () {
        if ($this->searchValue() === '') {
            return;
        }
        return $this->column->name.' = '. $this->escape($this->searchValue());
    });

from datatables.

13ran avatar 13ran commented on July 4, 2024

I just looked at the getQuery() log and that still causes the search term to be added to the query when its empty

from datatables.

n1crack avatar n1crack commented on July 4, 2024

Yea you are right, can you try this one ?

   $dt->filter('test_test', function () {
        if ($this->searchValue() === '') {
            return '';
        }
        return $this->column->name.' = '. $this->escape($this->searchValue());
    });

from datatables.

Related Issues (20)

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.