⚠ 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

Search Products in FLEXIGRID



Mrinal Rajpurohit
  • profile picture
  • Member

Posted 09 September 2012 - 10:31 AM

Hi,
I have used grocerycrud for the first time and i am amazed with the features.

I have a crud rendered with flexigrid. In the table i want a search feature for products as my client has more than 400 products. I know there is a search feature with flexigrid but unable to make it happen when rendered with grocerycrud.

Please guide.

Further,
My client has 100s of products spanned in several categories. Now when the table for products is rendered, i want a dropdown on top listing all the cateogries. The user chooses a category and products under that category should show up. Is this possible with grocerycrud?

Thanks.

victor
  • profile picture
  • Member

Posted 09 September 2012 - 11:17 AM

Hi Mrinal Rajpurohi!
Show your tables structure and your controllers code.

Mrinal Rajpurohit
  • profile picture
  • Member

Posted 10 September 2012 - 16:49 PM

Here goes the controller code:


function _example_output($output = null)
{
$data=array();
$data['main']='admin/products';
$data['title']='Products';
$this->load->vars($data);
$this->load->view('admin/form_template',$output);
}


function index()
{
$crud = new grocery_CRUD();
$crud->set_table('products');
$crud->set_subject('Product');
$crud->set_relation('category','categories','name');
$crud->set_field_upload('product_image','product_images/');
$crud->callback_after_upload(array($this,'thumbnailer'));
$crud->columns('name','category');
$crud->change_field_type('description','text');

$output = $crud->render();
$this->_example_output($output);
}

Table consists of following columns:

1. id (AI)
2. name (varchar)
3. category (int)
4. product_image (varchar)
5. price (int)
6. description (shorttext)

Thanks.

victor
  • profile picture
  • Member

Posted 10 September 2012 - 16:53 PM

Hi, show structure for the second table.
Do you have an error with this code when you doing search? what specific problems you are having?

Mrinal Rajpurohit
  • profile picture
  • Member

Posted 10 September 2012 - 17:26 PM

Second table is of categories with this structure:

1. Id (AI)
2. Name (varchar)
3. Furl (varchar)
4. Status (enum)

victor
  • profile picture
  • Member

Posted 10 September 2012 - 17:36 PM

Field must have a unique name, then the search will work correctly.
For example :
category
----------
cat_id
cat_name
cat_furl
cat_status.

products
-------------------

id (AI)
name (varchar)
category (int)
product_image (varchar)
price (int)
description (shorttext).
try it.

If you ignore this,you will have this error:
"Column 'name' in where clause is ambiguous".
Helped you in this matter?

Mrinal Rajpurohit
  • profile picture
  • Member

Posted 14 September 2012 - 16:56 PM

see, actually i can't even see a search field when the crud table is rendered...