Jump to content


davedriesmans

Member Since 31 May 2013
Offline Last Active Sep 18 2013 12:24 PM
-----

Topics I've Started

filter doesn't work on callback_column

13 September 2013 - 12:31 PM

hi,

 

it seems filtering/searching on a callback_column doesn't work. is it true and is there a workaround?

GENUS or Genus (Phylum) in the header is the callback column in this example.

 

best,

dave

 

in attach my code and an screenshot

 

function funbas()
{

        try{
            $crud = new grocery_CRUD();

            $crud->set_table('funbas');

            // call back for Genus - soortnaam
            $crud->callback_edit_field('GENUS',array($this,'dropdowngenusGroupMYC'));
            $crud->callback_add_field('GENUS',array($this,'dropdowngenusGroupMYC'));

            //  $crud->set_relation('GENUS', 'funbasGenus','genus');
            $crud->set_relation('categorie', 'funbasCategorie','categorie');
            $crud->set_relation('Eco1', 'funbasCdeEco','Functionele_groep');
            $crud->set_relation('Eco2', 'funbasCdeEco','Functionele_groep');
            $crud->set_relation('RLNL', 'funbasCdeRLNL', 'catNL');
            $crud->set_relation('RLVL', 'funbasCdeRLVL', 'catVL');
            $crud->set_relation('bibref', 'funbasBib', '{AUTEUR} - ({JAAR}) {bib_titel}');
            $crud->set_relation('status', 'funbasStatus', 'status');

            $crud->set_subject('funbas');
            $crud->columns('FUNBAS_ID', 'GENUS', 'SOORTNAAM', 'SPECIES', 'NEDNAAM', 'SYNONIEM', 'bibref', 'status', 'exportNR');
            $crud->display_as('GENUS','Genus (phylum)');
            $crud->order_by('GENUS asc, SOORTNAAM');


            $crud->callback_column('GENUS', array($this, 'genusGroupMYC'));
            $crud->callback_column('status', array($this, 'callbackStatus'));

            $output = $crud->render();
            $this->view_output_funbas($output, $data);


        }catch(Exception $e){
            show_error($e->getMessage().' --- '.$e->getTraceAsString());
        }
}




    /* funbas functions  */

    function genusGroupMYC($value)
    {
        $row=$this->Funbas_model->GetGenusGroupMYC($value);
        if (isset($row['genus_name'])) {
            $genusGroupMYC = $row['genus_name']. ' ('.$row['phylum'].')';
        } else {
            $genusGroupMYC = '-';
        }
        return $genusGroupMYC;
    }


    function dropdowngenusGroupMYC($value)
    {
        $funbasArray=$this->Funbas_model->GetGenusGroupMYC();

        $input = "<select name='GENUS' id='' class='chosen-select' data-placeholder='Select ...'>";
        $input .= '<option value=""></option>';
        foreach ($funbasArray as $row) {
            $selected = '';
            if ($row['ID'] == $value) {
                $selected = 'selected';
            }
            $input .= '<option value="'.$row['ID'].'" '.$selected.'>'.$row['genus_name'].' ('.$row['phylum'].')</option>';
        }
        $input .= '</select>';
        return $input;
    }

grocerycrud-callback.png

 


filter doesn't work on callback_column

13 September 2013 - 12:31 PM

hi,

 

it seems filtering/searching on a callback_column doesn't work. is it true and is there a workaround?

GENUS or Genus (Phylum) in the header is the callback column in this example.

 

best,

dave

 

in attach my code and an screenshot

 

function funbas()
{

        try{
            $crud = new grocery_CRUD();

            $crud->set_table('funbas');

            // call back for Genus - soortnaam
            $crud->callback_edit_field('GENUS',array($this,'dropdowngenusGroupMYC'));
            $crud->callback_add_field('GENUS',array($this,'dropdowngenusGroupMYC'));

            //  $crud->set_relation('GENUS', 'funbasGenus','genus');
            $crud->set_relation('categorie', 'funbasCategorie','categorie');
            $crud->set_relation('Eco1', 'funbasCdeEco','Functionele_groep');
            $crud->set_relation('Eco2', 'funbasCdeEco','Functionele_groep');
            $crud->set_relation('RLNL', 'funbasCdeRLNL', 'catNL');
            $crud->set_relation('RLVL', 'funbasCdeRLVL', 'catVL');
            $crud->set_relation('bibref', 'funbasBib', '{AUTEUR} - ({JAAR}) {bib_titel}');
            $crud->set_relation('status', 'funbasStatus', 'status');

            $crud->set_subject('funbas');
            $crud->columns('FUNBAS_ID', 'GENUS', 'SOORTNAAM', 'SPECIES', 'NEDNAAM', 'SYNONIEM', 'bibref', 'status', 'exportNR');
            $crud->display_as('GENUS','Genus (phylum)');
            $crud->order_by('GENUS asc, SOORTNAAM');


            $crud->callback_column('GENUS', array($this, 'genusGroupMYC'));
            $crud->callback_column('status', array($this, 'callbackStatus'));

            $output = $crud->render();
            $this->view_output_funbas($output, $data);


        }catch(Exception $e){
            show_error($e->getMessage().' --- '.$e->getTraceAsString());
        }
}




    /* funbas functions  */

    function genusGroupMYC($value)
    {
        $row=$this->Funbas_model->GetGenusGroupMYC($value);
        if (isset($row['genus_name'])) {
            $genusGroupMYC = $row['genus_name']. ' ('.$row['phylum'].')';
        } else {
            $genusGroupMYC = '-';
        }
        return $genusGroupMYC;
    }


    function dropdowngenusGroupMYC($value)
    {
        $funbasArray=$this->Funbas_model->GetGenusGroupMYC();

        $input = "<select name='GENUS' id='' class='chosen-select' data-placeholder='Select ...'>";
        $input .= '<option value=""></option>';
        foreach ($funbasArray as $row) {
            $selected = '';
            if ($row['ID'] == $value) {
                $selected = 'selected';
            }
            $input .= '<option value="'.$row['ID'].'" '.$selected.'>'.$row['genus_name'].' ('.$row['phylum'].')</option>';
        }
        $input .= '</select>';
        return $input;
    }

grocerycrud-callback.png

 


chosen is slow on IE for long lists

22 August 2013 - 09:33 AM

Grocery crud is using the chosen plugin for the relations, which is really nice.

However, in one of the relations i have 10k items. On IE9 and IE10 that is rendering really slow. What can i do?

 

 


set_relation with three tables

05 July 2013 - 12:29 PM

RDWN6.png

on top you have two tables and you can create a nice dropdown via:

$crud->set_relation('employees', 'offices', '{city} - ({country})');

 

BUT what if country was a relation with country_id and i want to fetch the country_name from a third table?


Photo Gallery with multiple fields : Image Crud or Crud with Callback_after_upload

04 July 2013 - 02:11 PM

hi,

 

i installed Image Crud and looks really nice.

My gallery table however has 10+ fields and some relations, is there a way to link the image with the grocery edit? (now it just opens a lightbox)

 

or should use the base Crud and do a callback_after_upload to have different image sizes? But then there is now way to get a proper gallery in the overview...  :)

 

Dave