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

TOPIC:

Multiselect on FK single select list filter 07 Dec 2016 16:27 #14826

  • MorganL
  • MorganL's Avatar Topic Author
  • Offline
  • Platinum Member
  • Platinum Member
  • Posts: 438
  • Thank you received: 53
So I have a single choice category field for a table which is linked to a table called cetegories.

At present the filter is a single choice dropdown, however it would be nice if this could be a LIST filter.

ANyone already written a class or manually written a multselect dropdown based on a 1:n dropdown?

I have already tried the list filter but that appears geared around n:n
Morgan Leecy MCSE

Novell / Linux
PHP. MYSQL, Apache, node.js
Coldfusion, JQuery, HTML5
Joomla

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

Last edit: by MorganL.

Multiselect on FK single select list filter 07 Dec 2016 18:34 #14827

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 986
he he... lol
It is coming soon.

List filter over Foreign Keys. (1:N)
Patience. It is the next step. I'd like also to create the Radio button for choosing the logic.

Note : Obviously (by context design), the List filter will never apply to a N:1, because it is a non-sens. It would always return 1 result.
In such case, the information is retrieved through the Parent item FK.
Need more explanations about this details ? Make sense for you ?
Coding is now a piece of cake
The following user(s) said Thank You: MorganL

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

Multiselect on FK single select list filter 07 Dec 2016 21:51 #14833

  • MorganL
  • MorganL's Avatar Topic Author
  • Offline
  • Platinum Member
  • Platinum Member
  • Posts: 438
  • Thank you received: 53
I actually got this working with minimal hacking

First in the model XML file I chanfed the filter type

This
<field name="filter_genres"
				listKey="id"
				labelKey="genre"
				type="ckcombo"
				nullLabel="COMPONENT_FILTER_NULL_FILTER_GENRE"
				class="span-2 element-filter"
				label="COMPONENT_JSEARCH_FILTER_BY_GENRE"
				ui="chosen"/>

became this
<field name="filter_genres"
			   type="relation"
			   submit="true"
			   placeholder="COMPONENT_FILTER_NULL_FILTER_GENRE"
			   label="COMPONENT_JSEARCH_FILTER_BY_GENRE"
			   class="element-filter"
			   ui="chosen"
			   filter="array"
			   multiple="true"
			   relation="genres"
			   labelKey="genre"/>

I altered the WHERE statement in the prepareQuery from

This
	//WHERE - FILTER : Genre
        if($filter_genres = $this->getState('filter.genres'))
        {
            if ($filter_genres > 0){
                $this->addWhere("a.genres IN (" . (int)$filter_genres . ")");
            }
        }

to this
        //WHERE - FILTER : Genre

if($filter_genres = $this->getState('filter.genres'))
{
    
    
if (count($filter_genres) > 1 || (count($filter_genres) == 1 && array_sum($filter_genres) > 0)){
        
$string = ltrim(implode(',', $filter_genres), ',');
        
$this->addWhere("a.genres IN (" . $string . ")");
    
}

}

for some reason after one search, the array kept passing a null value which messed it up so I had to look for the null value and ignore

And in the same model file in the __construct function I changed this
$this->set('filter_vars', array(
			'genres' => 'cmd',

to this
$this->set('filter_vars', array(
			'genres' => 'array',

uploaded and it seems to do the trick
Morgan Leecy MCSE

Novell / Linux
PHP. MYSQL, Apache, node.js
Coldfusion, JQuery, HTML5
Joomla
The following user(s) said Thank You: jonathanbell

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

Last edit: by MorganL.

Multiselect on FK single select list filter 07 Dec 2016 21:59 #14834

  • MorganL
  • MorganL's Avatar Topic Author
  • Offline
  • Platinum Member
  • Platinum Member
  • Posts: 438
  • Thank you received: 53
yup after much testing, work exactly as I expected! Beat you too it, though I am sure my solution will not match your solution
:-)
Morgan Leecy MCSE

Novell / Linux
PHP. MYSQL, Apache, node.js
Coldfusion, JQuery, HTML5
Joomla

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

Multiselect on FK single select list filter 12 Dec 2016 14:35 #14837

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 986
Added since 3.0.10
www.j-cook.pro/index.php/docs/versions/282-3-0-10


Thank you for your inspiration.
Now you can delete your fork.

For the moment the labels of the List filters are missing and very messy for changing the placeholder.

So I am reviewing the whole HTML layout for the ugly filters. (Next feature)
Coding is now a piece of cake
The following user(s) said Thank You: MorganL

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

Multiselect on FK single select list filter 12 Dec 2016 14:52 #14838

  • MorganL
  • MorganL's Avatar Topic Author
  • Offline
  • Platinum Member
  • Platinum Member
  • Posts: 438
  • Thank you received: 53
Yeah the generic placeholder text for that type of filter could do with a rework.

Thanks for getting this in!
Morgan Leecy MCSE

Novell / Linux
PHP. MYSQL, Apache, node.js
Coldfusion, JQuery, HTML5
Joomla

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

Multiselect on FK single select list filter 12 Dec 2016 15:09 #14839

  • MorganL
  • MorganL's Avatar Topic Author
  • Offline
  • Platinum Member
  • Platinum Member
  • Posts: 438
  • Thank you received: 53
I have purged my browser cache and restarted, unable to drag an FK into a list filter

1) I drag in the new LIST filter
2) I expand my FK and pull in the string field I want to form the label but it does not 'release', the filter stays blank

I have also tried dragging the whole FK field
Morgan Leecy MCSE

Novell / Linux
PHP. MYSQL, Apache, node.js
Coldfusion, JQuery, HTML5
Joomla

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

Multiselect on FK single select list filter 12 Dec 2016 15:18 #14840

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 986
Browser cache, (try again)
or maybe because your FK field is already instanced in another filter.
Coding is now a piece of cake
The following user(s) said Thank You: MorganL

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

Multiselect on FK single select list filter 12 Dec 2016 15:25 #14841

  • liubov
  • liubov's Avatar
  • Offline
  • Elite Member
  • Elite Member
  • (=) 10 mn and it's ready!
  • Posts: 279
  • Thank you received: 36
Very usefull feature!
++ Don't forget ENUM compatibility for List Filters, will be top :)

Thanks!

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

Last edit: by liubov.

Multiselect on FK single select list filter 12 Dec 2016 16:37 #14842

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 986
Ok, I will...
Cook Is build open & abstracted, so it might not be a big deal.

Discover the new FormHelper, it is a bit complicated, but it is because I want to rewrite all the ugly fields.
Avoid JDom at maximum and achieve the work with the FormHelper
Inherit the fields from Joomla fields to extend them and no Field superclass anymore.
A long program. I hope you will not be lost. It is becoming more native since Joomla integrate the correct code.
Coding is now a piece of cake

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

Multiselect on FK single select list filter 12 Dec 2016 17:31 #14843

  • liubov
  • liubov's Avatar
  • Offline
  • Elite Member
  • Elite Member
  • (=) 10 mn and it's ready!
  • Posts: 279
  • Thank you received: 36
Yes I hope too ! ;)

But I learned a lot when peeling j-cook code, and it's great to find the good code to the good place :)
So with practice, it becomes more and more easy to customize our own specificities.
I am not worried for joomla/j-cook future

Marc
The following user(s) said Thank You: admin

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

Last edit: by liubov.

Multiselect on FK single select list filter 12 Dec 2016 17:39 #14844

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 986
And because we talk about those special filters, let's tell you something else : ORM

The special functions used by prepareQuery() :
- filterPivot()
- filterMulti()
- prepareQueryAccess()
- propagateAccess...
All this stuff will be compiled and called only with namespaces. Introduction of ORM (Object Relation Maps).
Your component knows the relations so you will not need anymore to think about your SQL.

In future, Just ask : "country.continent", and the component will do the rest.
Same for filters, and pagination... bla bla...
It will save hours of coding and avoid the SQL errors.

Stay tuned, this is coming slowly but the source code is already using those functions.
Cook is a passion for me. I love it so much !
Coding is now a piece of cake
The following user(s) said Thank You: Romkabouter

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

Multiselect on FK single select list filter 12 Dec 2016 19:13 #14845

  • liubov
  • liubov's Avatar
  • Offline
  • Elite Member
  • Elite Member
  • (=) 10 mn and it's ready!
  • Posts: 279
  • Thank you received: 36
whaoo, great roadmap...
It's the logic next generation of the Builder, ORM is also a good deal to reduce the duplicated code to manage CRUD operations ...

admin wrote: Cook is a passion for me. I love it so much !

And this is what we feel as users of j-cook self service!

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

Multiselect on FK single select list filter 12 Dec 2016 20:08 #14846

  • MorganL
  • MorganL's Avatar Topic Author
  • Offline
  • Platinum Member
  • Platinum Member
  • Posts: 438
  • Thank you received: 53

admin wrote: Browser cache, (try again)
or maybe because your FK field is already instanced in another filter.


You called it, that was exactly it. Thanks!
Morgan Leecy MCSE

Novell / Linux
PHP. MYSQL, Apache, node.js
Coldfusion, JQuery, HTML5
Joomla

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

Multiselect on FK single select list filter 05 Jul 2017 23:22 #15236

So, I'm confused sorry guys. Sounds like in this post that we can now make a list multi select which is very useful. But I cannot see how this works in Jcook builder. What am i missing?

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

Last edit: by jonathanbell. Reason: Spelling mistake
  • Page:
  • 1
  • 2
Time to create page: 0.105 seconds

Just wanted to congratulate you on the J-Cook website / web development tool. In a couple of visits I've had a play around with Cook and have to say I think it is fantastic.  I've played with a number of component builders in the past and yours is certainly looking like the best so far. I'd also like to help you spread the word - I'm really surprised more people aren't excited about this tool. Good luck with the project.
Dean

Get Started