Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1

TOPIC:

[FIXED] Preffilled values from filters 23 Apr 2012 14:40 #2113

  • liubov
  • liubov's Avatar Topic Author
  • Offline
  • Elite Member
  • Elite Member
  • (=) 10 mn and it's ready!
  • Posts: 279
  • Thank you received: 36
EDIT ADMIN : follows this post :

www.j-cook.pro/forum/12-new-functionalit...13-re-context-layout



Thank you ! me too !!!


Just one more info:

I - When I started to use j-cook, and check my component in the sandbox, the behaviours of Filters was 'normal' between the grid (items view) and Form (new item).
If active filters were setted in the grid => they were auto selected when adding a new item.

I checked the generated code, and I think the job is prepared because I saw that to set the new data :
			$data->id_race = JRequest::getInt('filter_id_race');
			$data->id_etalon = JRequest::getInt('filter_id_etalon');
			$data->id_lice = JRequest::getInt('filter_id_lice');
			$data->id_statut = JRequest::getInt('filter_id_statut');

BUT ::

Here, the JRequest::getInt('filter_id_xxxxx'); always returns 0 (zero)

so I have added that in the item model to load the right filter value ...
	// for $filter_id_race, context never change to conserve filter on each page ...
	// $filter_id_race = $app->getUserStateFromRequest('filter.id_race', 'filter_id_race');

	$this->setState('filter.id_race', $filter_id_race, null, 'int');

Tell me when updated ...

Marc

Please Log in or Create an account to join the conversation.

Last edit: by admin.

Preffilled values from filters 24 Apr 2012 08:36 #2116

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 986
It probably went down, when I upgraded for the new MVC structure. (since 1.6)

I check this.
Coding is now a piece of cake

Please Log in or Create an account to join the conversation.

Re: Preffilled values from filters 27 Apr 2012 08:12 #2155

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 986
Everything is now working but not live yet.

I will tell you after the next upgrade (few days)
Coding is now a piece of cake

Please Log in or Create an account to join the conversation.

Re: Preffilled values from filters 30 Apr 2012 13:37 #2187

  • liubov
  • liubov's Avatar Topic Author
  • Offline
  • Elite Member
  • Elite Member
  • (=) 10 mn and it's ready!
  • Posts: 279
  • Thank you received: 36
Hi Joce !

Another question on this theme ...

I am trying to set some filters default value into the Items pages (grid).

Purpose is to prefit mains filters to obtain a usefull view. For me and my component, prefit the filter 'dogs status' to : 'Belong to the breed' (Appartient à l'élevage) to see directly all the dogs of my Breed ...

Also to present my component with prefitted filtered views...

So In 1.5 I was using the default value of filter, setting int ID instead of 'null' value. But with your code, it does not work.
$this->setState('filter.id_statut', $filter_id_statut, null, 'int');
$this->setState('filter.id_statut', $filter_id_statut, 2, 'int');

Why id is not retained and setted into the filter ?
Another way ?

Thanks

Marc.

Please Log in or Create an account to join the conversation.

Last edit: by liubov.

Re: Preffilled values from filters 01 May 2012 20:10 #2196

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 986
Regarding Opened ticket, now it is working.
There has been lot of changes (layout name is not anymore included in the namespace for filters)


Now your problem :
$this->setState('filter.id_statut', $filter_id_statut, null, 'int');

This changes the state of the filter, but does not affect permanent session value.
You should change this at the level of JFactory::Application : (from memory)


JFactory::getApplication()->setUserState('filter.id_statut', $filter_id_statut);

EDIT :
$this->context = "com_xxxx.myview";
JFactory::getApplication()->setUserState($this->context . '.filter.id_statut', $filter_id_statut);
That's it
Coding is now a piece of cake
The following user(s) said Thank You: liubov

Please Log in or Create an account to join the conversation.

Last edit: by admin.

Re: Preffilled values from filters 02 May 2012 03:19 #2201

  • liubov
  • liubov's Avatar Topic Author
  • Offline
  • Elite Member
  • Elite Member
  • (=) 10 mn and it's ready!
  • Posts: 279
  • Thank you received: 36
Hi Jocelyn,

Tanks for your reply, but there were 2 questions in that post about filters:

1 => session filters => Thanks, ok I ve anderstood .
2 => default value filter, if i want to choose a defaut value, I set the id instead of null value, but no change into the view...
$this->setState('filter.id_statut', $filter_id_statut, 2, 'int');

( May be it was better to open another post for that... )

Marc.

Please Log in or Create an account to join the conversation.

Re: Preffilled values from filters 02 May 2012 07:51 #2213

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 986
Defaults states values of models :

The best place is in popolateState() function of the concerned model.
There, you can find getState() calls.
Define the default value within
Coding is now a piece of cake

Please Log in or Create an account to join the conversation.

Re: Preffilled values from filters 02 May 2012 09:29 #2217

  • liubov
  • liubov's Avatar Topic Author
  • Offline
  • Elite Member
  • Elite Member
  • (=) 10 mn and it's ready!
  • Posts: 279
  • Thank you received: 36
Completly agree with you, and it's what I've done.
	protected function populateState($ordering = null, $direction = null)
	   {
		// Initialise variables.
		$app = JFactory::getApplication();
		$session = JFactory::getSession();

		// Adjust the context to support modal layouts.
		if ($layout = JRequest::getVar('layout')) {
			$this->context .= '.'.$layout;
		}
		
		// for $filter_id_race context never change to conserve filter on each page ...
		$filter_id_race = $app->getUserStateFromRequest('filter.id_race', 'filter_id_race');
		$this->setState('filter.id_race', $filter_id_race, null, 'int');

                .....

		$filter_id_statut = $app->getUserStateFromRequest($this->context.'.filter.id_statut', 'filter_id_statut');
		$this->setState('filter.id_statut', $filter_id_statut, 2, 'int');

                ......

		parent::populateState();
	   }

Normaly, if $filter_id_statut is null (meaning no filtered), the default value '2' is setted to 'filter.id_statut', but as I said, it does not work...
Of course I can add a line to test the value of $filter_id_statut like that :
$filter_id_statut = $app->getUserStateFromRequest($this->context.'.filter.id_statut', 'filter_id_statut');
        if ( empty($filter_id_statut)) { 
            $this->setState('filter.id_statut', 2, null, 'int'); 
        } else {
            $this->setState('filter.id_statut', $filter_id_statut, null, 'int'); 
        }

it works, but it is not a nomal behaviours, isn't it ?


Marc.

Please Log in or Create an account to join the conversation.

Last edit: by liubov.
  • Page:
  • 1
Time to create page: 0.074 seconds

I jumped and started to work on a demo component... but 2 days later this demo component became the real component. I just showed today the end result to my customer and he turned to me and said... "this is more than I expected"... All of this is because Cook did cut about 70% of my work and provided me more ways to improve the usability of the component. The end result was 17 tables all related between than to generate a full dashboard for the travel agents. Thanks for Cook developers for such great tool. This component would not be possible to be done at short time with all the features in it
Griiettner (Forum)  

Get Started