Datatable icon indicating copy to clipboard operation
Datatable copied to clipboard

Cannot apply individual column searching

Open maspan opened this issue 10 years ago • 9 comments

Hello Chumper, Using the below doesn't work for search columns. It still gives me one option to search as in classic datatable views.

public function getDatatable()
{
    return Datatable::collection(User::all(array('id','name', 'address')))
    ->showColumns('id', 'name', 'address')
    ->searchColumns(array('name', 'address'))
    ->orderColumns('id','name')
    ->make();
}

Thanks /maspan

maspan avatar Aug 29 '14 20:08 maspan

do you have an example?

Chumper avatar Sep 15 '14 17:09 Chumper

I couldn't understand how this could work. The search field is only one textbox in the datatables grid, and it searches using the column of the array searchColumns. So what happens if I add more in that array?

maspan avatar Sep 17 '14 09:09 maspan

Hi Nils, i have an example about the "Individual column searching via ajax" that you can search any columns via typing at very end of every column inputbox. You can see the examples; https://datatables.net/examples/api/multi_filter.html (with text input) and http://www.datatables.net/examples/api/multi_filter_select.html (with select) (but this one is not quite necessary i think).

parabol avatar Oct 19 '14 12:10 parabol

Hi Chumper, I would like to set up an example like this one : https://datatables.net/examples/api/multi_filter.html
Is it possible with Chumper/Datatable ?

Can I use it from a controller like this way ? Example :

    public function index()
    {
        // Datatable
        $table = Datatable::table()
        ->addColumn('Nom','Prénom','Age','Datejour','Actions')
        ->setUrl(route ('api.utilisateurs'))
        ->setClass('table table-bordered table-hover table-striped table-condensed dataTable no-footer ') 
        ->setOptions(array('language' => array('url'=> '/localisation/FR_fr.json'), 
            'searchHighlight' => true,

                           )
                    ) 
        ->noScript();

        Return View::make('utilisateurs.index', array('table' => $table));
    }
public function apigetUtilisateurs()
        {
        //
            return Datatable::collection(Utilisateur::all(array('nom', 'prenom','age','datejour','id')))
            ->showColumns('nom', 'prenom','age','datejour')
            ->addColumn('id', function($model){
                return '<a href="/utilisateursTEST/' . $model->id . '">view</a>';
            })
            ->searchColumns('nom','prenom')
            ->orderColumns('nom','prenom','age','datejour')
            ->make();
        }

Thanks by advance

paguemaou avatar Nov 17 '14 13:11 paguemaou

I've found this closed message :
https://github.com/Chumper/Datatable/issues/52 There's a little bug (see my comment at the end) Hope this helps.

paguemaou avatar Nov 17 '14 15:11 paguemaou

what happend?? yo can do that? I want to do the same, but fnFilter dosnt Work with custom column index.

Razielini avatar Nov 25 '14 23:11 Razielini

I'm with the same problem. How can I fix it?

aron-bordin avatar Jan 18 '15 19:01 aron-bordin

Did you try it with my explanation in #52 ?

Chumper avatar Jan 18 '15 21:01 Chumper

Yep, but I could not fix it reading #52. My project was fixed with #224

aron-bordin avatar Jan 18 '15 22:01 aron-bordin