⚠ 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 without display in coloumn



Hasan Busro
  • profile picture
  • Member

Posted 24 April 2013 - 01:11 AM

Hii all.

Can I create a filter without displaying fields in columns?
In other words, I want the value of a field can be searched, but the field is not displayed in the column.
How to do it?


jjwdesign
  • profile picture
  • Member

Posted 27 April 2013 - 16:51 PM

Yes, there is a way of doing it. Use the callback_column() method to revise the column details. For example, my title column was changed to add some additional search keywords (ie display: none) to make the JavaScript search functionality of datatables search better.

 

http://www.grocerycrud.com/documentation/options_functions/callback_column

 

Add the call back for the existing title column.

 

$crud->callback_column('title', array($this, '_rev_title'));

 

Use the callback to add the keywords into the column with style display none.

 

    function _rev_title($value, $row) {
        
        return htmlspecialchars($value) . 
            '<span style="display:none;"> ' . 
            htmlspecialchars(str_replace(',',' ', $row->search_keywords)) . 
            ' </span>';
    }

 

I used a Keyword Generating library to create the keywords. You don't have to use the keywords. You can use whatever fields you wish to add into the hidden span.

 

https://github.com/peterkahl/multibyte-keyword-generator

 

To generate the keywords on edit/add save. You'll need to look at several more callbacks. Something like...

 

$crud->callback_after_insert(array($this, '_callback_after_insert'));

$crud->callback_after_update(array($this, '_callback_after_update'));

 

But, I'll leave that up to you.


Hasan Busro
  • profile picture
  • Member

Posted 02 May 2013 - 04:06 AM

Hi jjwdesign, thanks for your reply. But I still can not use the class "keyword-multibyte-generator" (https://github.com/peterkahl/multibyte-keyword-generator). I've tried to implement it by using it as a helper, but to no avail. If you have time, share it with me to tell it. Or maybe you have a code that I can in this instance.

Thank you very much