⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠

  •     

profile picture

filter doesn't work on callback_column



davedriesmans
  • profile picture
  • Member

Posted 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

 


davidoster
  • profile picture
  • Member

Posted 13 September 2013 - 19:39 PM

The callback_add_field function doesn't accept a parameter.

The callback_edit_field function does accept two parameters.

You need to either make two callback functions or use the callback_field instead.

Also the callback function for the callback_column needs to have two parameters $value, $row.

 

Check the manual again.

 

Check if this solves the problem.


Amit Shah
  • profile picture
  • Member

Posted 14 September 2013 - 02:08 AM

Hi davedriesmans

 

first off all.. Mr. David is very much correct. You need to alter the code accordingly.

 

Second .. to your query - yes - technically filter is not possible for the callback column. Filter occurs on the server side (using a query) .. if the callback column dose not have a field name - it will give you error in query itself. For the same if you wish to have filter - will recomend that you have a custom filter built over the grid and filter it accordingly.

Secondly - if your trouble is - when you are having a callback column and you are trying to filter any record and it is not happening / failing in.. then you need to refer to this post. It surely will help you solve this second issue.


davidoster
  • profile picture
  • Member

Posted 14 September 2013 - 06:33 AM

[member=amit shah], I forgot about this post you did!!! Ignore my previous message on this thread also! ;)