⚠ 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

Change field order



Wathfea
  • profile picture
  • Member

Posted 25 August 2013 - 14:16 PM

Hi All,

Is there a way to change the view order of the fields?
For example I have a table      test and i have some columns in it: id, name, title, address
If i use the crud it display the fields the same order. But what if I would like to change it, so in my Add record page I wish to see this:    id field, title field, name field and address field. Is it possible or I have to change the structure of my table?

Thx a lot


Wathfea
  • profile picture
  • Member

Posted 25 August 2013 - 15:12 PM

I solved it. :)

Did it via the mysql database and I used this:
ALTER TABLE my_table MODIFY COLUMN field1 int(11) AFTER field2;


Amit Shah
  • profile picture
  • Member

Posted 25 August 2013 - 15:39 PM

well the other way around was you could have set the name order in columns table. The order in which it they are set will be displayed.


Mohamed Rafiq
  • profile picture
  • Member

Posted 28 August 2013 - 04:22 AM

U could change the displaying order like "Amit shah said". Example

 

If ur table column : Student, Age, Gender and if u want to display like Gender, Student Name, Age means

 

you can change the order in grid list by 

 

List page    : $crud->columns('Gender',Student Name','Age');

If u want to do the same thing in add page means

 

Add Page   : $crud->add_fields('Gender',Student Name','Age');

Edit Page   : $crud->edit_fields('Gender',Student Name','Age');


mnish
  • profile picture
  • Member

Posted 01 September 2013 - 17:25 PM

you can use $crud->column('field1','field2'); it shows list you also set field order in edit by $crud->fields('field1','field2');


infinito1971
  • profile picture
  • Member

Posted 12 May 2015 - 08:57 AM

Hi all,

why this doesn't work in the record's fields order (click on magnifying glass in table list records)?


infinito1971
  • profile picture
  • Member

Posted 13 May 2015 - 10:39 AM

Hi All,
I solved the problem adding to public function fields() in Grocery_CRUD.php the following row:
$this->read_fields = $args;
I hope this will help.
 
 
Bye,
infinito1971

infinito1971
  • profile picture
  • Member

Posted 13 May 2015 - 12:23 PM

Probably, a better solution is add a new function as the following:

	public function view_fields()
	{
		$args = func_get_args();

		if(isset($args[0]) && is_array($args[0]))
		{
			$args = $args[0];
		}

		$this->read_fields = $args;

		return $this;
	}

Bye,

infinito1971