marqu3s / yii2-behaviors

Collection of Yii2 Behaviors to enhance Grids and ActiveRecord models.
MIT License
11 stars 4 forks source link

sessionVarName #3

Closed ric128 closed 2 months ago

ric128 commented 6 years ago

Hi Marqu3s I tried to change the "sessionVarName""GridFilters" to "myOwnNameGridFilters" but it doesn't work. Why? or how can I change the sessionVarName? Thank you.

marqu3s commented 6 years ago

Hi!

Can you show me your code?

Atenciosamente, João Marques

Em 22 de fev de 2018 10:34 -0300, ric128 notifications@github.com escreveu:

Hi Marqu3s I tried to change the "sessionVarName""GridFilters" to "myOwnNameGridFilters" but it doesn't work. Why? or how can I change the sessionVarName? Thank you. — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

ric128 commented 6 years ago

This works

class BncCuentasSearch extends BncCuentas {

public function behaviors()
{
  return [
    'saveGridFilters' =>[
      'class' => SaveGridFiltersBehavior::className(),
      'sessionVarName' => self::className() . 'GridFilters'
    ],
    'saveGridPage' =>[
      'class' => SaveGridPaginationBehavior::className(),
      'sessionVarName' => self::className() . 'GridPage'
    ]
  ];
}

public function search($params)
{
    $this->load($params);

    $dataProvider= new SqlDataProvider([...........

    $dataProvider = $this->loadWithFilters($params, $dataProvider); 
    $dataProvider->pagination->page = $this->getGridPage();

    return $dataProvider;
}

This doesn't work.

class BncCuentasSearch extends BncCuentas {

public function behaviors()
{
  return [
    'saveGridFilters' =>[
      'class' => SaveGridFiltersBehavior::className(),
      'sessionVarName' => self::className() . 'MyOwnNameGridFilters'
    ],
    'saveGridPage' =>[
      'class' => SaveGridPaginationBehavior::className(),
      'sessionVarName' => self::className() . 'GridPage'
    ]
  ];
}

public function search($params)
{
    $this->load($params);

    $dataProvider= new SqlDataProvider([...........

    $dataProvider = $this->loadWithFilters($params, $dataProvider); 
    $dataProvider->pagination->page = $this->getGridPage();

    return $dataProvider;
}
marqu3s commented 2 months ago

No interaction in a long time.