Yii Framework Forum: Session Variables: Select columns - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • This topic is locked

Session Variables: Select columns

#1 User is offline   taikimizuno 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 4
  • Joined: 27-August 14

Posted 28 November 2014 - 07:18 PM

Hi Guys.

The reason for this, is I need some help with the following case:

I'm implementing a grid.CGridView for a table whose information must be brought based on the columns selected by the user, via checkboxes.
That is, if my table has 8 columns, then 8 checkbox are displayed, and the user selects 5 columns, and then he clicks the submit for the CGridView refreshes and shows the selected columns.

The detail is that the selected columns are storing in session variables through a private function that i'm calling on my admin controller (where is my table):

We must clarify that there is an array of checkboxes with the names of the columns in the table ($ _POST ['columnas']).

private function fijarColumnasAdmin()
Yii::app()->session['adminMoviles'] = array("nombre");
Yii::app()->session['adminMoviles'] = $_POST['columnas'];
//Yii::app()->session['adminMoviles'] = array();

And I have a double trouble:

- In the line that I have put the '//', if I commented it, it preserves the columns that I have selected, even when I advance on the pager of my table and/or I navigate in my web application, but it hasthe disadvantage that if I do not select any columns, then not shows my empty table, but I get the last columns I selected.

- And if it is uncommented: when I refresh the table after selecting some columns, then when I advance on the pager and / or I move in different parts of the application and return to the myTable/admin, The selected columns are lost.

My question is:
What could I do to ensure I do not miss my selected columns (selecting or not selecting columns), when I use the pager of my table and/or I move in different parts of my application until I return again to myTable/admin ?

Thanks for your attention.

Share this topic:

Page 1 of 1
  • You cannot start a new topic
  • This topic is locked

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users