Welcome, Guest
Username: Password: Remember me

TOPIC: Filter list by first filter value - by default

Filter list by first filter value - by default 22 Jun 2012 13:18 #2616

Hi again,

I have a filter called 'fund_entry_state' which is using a lookup table (see my previous thread).

How can I make it so that the list view, by default, is filtered by one of these values as apposed to none?

Best regards,
K...
The administrator has disabled public write access.

Re: Filter list by first filter value - by default 25 Jun 2012 09:22 #2637

OK, I realise I cannot set this from the J-Cook UI so I'll have to manually set my desired filter option as the default! Unless of course I am mistaken, please tell me if I am.

Thanks,
K...
The administrator has disabled public write access.

Re: Filter list by first filter value - by default 25 Jun 2012 09:42 #2640

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 987
  • Karma: 140
Yes, Cook cannot define default filter values.

Some hardcode is needed in the populateState() function of your concerned model.
Coding is now a piece of cake
The administrator has disabled public write access.

Re: Filter list by first filter value - by default 25 Jun 2012 14:19 #2655

Thanks Admin, don't suppose you have an example of making such a change do you? ;-)
The administrator has disabled public write access.

Re: Filter list by first filter value - by default 02 Nov 2012 15:15 #4941

I too would also like to know the process to have a list view filtered by default. I have a rental properties table and don't really want the "Rented" properties to show. In backend the "status" is a required data field.

Any help would be appreciated. B)
The administrator has disabled public write access.

Re: Filter list by first filter value - by default 02 Nov 2012 15:44 #4942

  • JoomGuy
  • JoomGuy's Avatar
  • Offline
  • Moderator
  • Joomla Enthusiast, Lover of Cooking
  • Posts: 1115
  • Thank you received: 195
  • Karma: 64
You'd need to use the populateState() function of your concerned model.

So, if your field is status, you need to filter by status...

Look at the filter by published (you'll find this in your model):
//Only show the published items
		if (!$acl->get('core.admin') && !$acl->get('core.edit.state'))
			$this->setState('filter.published', 1);

Hope it helps,

Gez
Need help with your Cook/Joomla Project? . PM me to find out what I can help with. NO time wasters please!!!
The administrator has disabled public write access.
The following user(s) said Thank You: admin

Re: Filter list by first filter value - by default 02 Nov 2012 17:34 #4950

Yea that's a little over my head. More designer, less coder.

Don't really understand this...
Look at the filter by published (you'll find this in your model):

OK I think your referring to - root > components > mycomponent > models > mycomponent.php correct??

I see query statements in this php file. Could I simply change the SELECT * ?

Had another thought cross my feeble mind. Could I simply create a "Publish/Unpublish" selector in the Joomla backend? How hard is that? I'm sure outside of Cook.
The administrator has disabled public write access.

Re: Filter list by first filter value - by default 02 Nov 2012 17:46 #4951

  • JoomGuy
  • JoomGuy's Avatar
  • Offline
  • Moderator
  • Joomla Enthusiast, Lover of Cooking
  • Posts: 1115
  • Thank you received: 195
  • Karma: 64
You could just just change the query but you need: ROOT/administrator/components/com_yourcomponentname/models/modelname.php

Check here: www.j-cook.pro/forum/9-coding-inside-you...tering-in-items#4500 for which query to add a case statement to.

Publishing is simple (inside cook)... Once you have a published field on your table (using wizards > publishing) you can simply add a filter (combo type) to the filters part of your admin list (grid view) then drag your field to the filter. There is a slight bug with this at the moment though if I remember correctly... Maybe not the way to go for you ATM.

___________________

Brainwave... What kind of field are you using for status? An enum field? or is it a foreign key?

You can filter on those in the grid view easily as described above for filtering published... Except, there is no bug there, it is working perfectly.

Gez
Need help with your Cook/Joomla Project? . PM me to find out what I can help with. NO time wasters please!!!
The administrator has disabled public write access.

Re: Filter list by first filter value - by default 02 Nov 2012 18:03 #4954

Wow! Had no idea what the Wizards were. Thought maybe they were little scripts that helped you build. There was a published wizard. Simple as pie.

Wish there was more Docs about features. Or more in depth videos.

Thanks so much got it working perfect.
Last Edit: 02 Nov 2012 18:05 by SproutCreatives.
The administrator has disabled public write access.

Re: Filter list by first filter value - by default 02 Nov 2012 18:12 #4956

  • JoomGuy
  • JoomGuy's Avatar
  • Offline
  • Moderator
  • Joomla Enthusiast, Lover of Cooking
  • Posts: 1115
  • Thank you received: 195
  • Karma: 64
No probs...

I'd really recommend creating a couple of simple dummy projects to test how all of the features work before getting in to building anything too serious. It'll really help you to design your component.

Glad it helped!

Gez
Need help with your Cook/Joomla Project? . PM me to find out what I can help with. NO time wasters please!!!
The administrator has disabled public write access.
Time to create page: 0.088 seconds

Get Started