⚠ In case you've missed it we are migrating 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 forum is read-only and soon will be archived. ⚠


Change field order


  • Please log in to reply
7 replies to this topic

#1 Wathfea

Wathfea

    Member

  • Members
  • PipPip
  • 19 posts

Posted 25 August 2013 - 02: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



#2 Wathfea

Wathfea

    Member

  • Members
  • PipPip
  • 19 posts

Posted 25 August 2013 - 03: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;



#3 Amit Shah

Amit Shah

    grocery CRUD Master

  • Advanced Member
  • PipPipPip
  • 1,192 posts

Posted 25 August 2013 - 03: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.



#4 Mohamed Rafiq

Mohamed Rafiq

    Newbie

  • Members
  • Pip
  • 4 posts

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');



#5 mnish

mnish

    Member

  • Members
  • PipPip
  • 23 posts

Posted 01 September 2013 - 05:25 PM

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



#6 infinito1971

infinito1971

    Newbie

  • Members
  • Pip
  • 6 posts

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)?



#7 infinito1971

infinito1971

    Newbie

  • Members
  • Pip
  • 6 posts

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


#8 infinito1971

infinito1971

    Newbie

  • Members
  • Pip
  • 6 posts

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






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users