⚠ 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

How do I show Primary Key in my table.



kelwenzera
  • profile picture
  • Member

Posted 02 November 2012 - 00:32 AM

Hey guys, I'm new here and first of all, groceryCRUD is great!

Now.. I've been searching for it and I can't find the solution, I searched and searched and couldn't find any 'problem' like mine.

The table is fine, showing all the data I want even with set_relation, working like a charm. What I want is just show the primary key in my table, so I could do a search by the ID(PK) or anything else.
I need it in my tables, because sometimes I just need the ID(PK) in order to make a fast search and edition.

Can someone help me? What do I need to do, what do I have to change...

Thanks in advance!

victor
  • profile picture
  • Member

Posted 02 November 2012 - 06:01 AM

Hi, kelwenzera and welcome to the forum!
You can use the callback function "columns".

$crud->columns('[color=#ff0000]id[/color]','name', and other fields);

kelwenzera
  • profile picture
  • Member

Posted 02 November 2012 - 17:17 PM

Thanks so much Victor, I saw that function, but didn't believe that was going to work. Thanks! Now everything is more than perfect!

phamhongson.np
  • profile picture
  • Member

Posted 23 October 2014 - 04:29 AM

go to: application\libraries\Grocery_CRUD.php

find: $this->columns = array();

it is in  function: get_columns()

add below line : $this->columns[] = $this->get_primary_key();


vampirekiller
  • profile picture
  • Member

Posted 06 February 2017 - 03:14 AM

go to: application\libraries\Grocery_CRUD.php

find: $this->columns = array();

it is in  function: get_columns()

add below line : $this->columns[] = $this->get_primary_key();

 

Any one please! how to do to work search function for primary_key ? :(


vampirekiller
  • profile picture
  • Member

Posted 06 February 2017 - 03:17 AM

I show primary key with $crud->columns('id','name', and other fields);  and then i see id field in list. but search function is not work for id field. how do i need to do to search primary key(id)