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

TOPIC: [ADDED] Multiselect on FK single select list filter

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

  • MorganL
  • MorganL's Avatar
  • Offline
  • Platinum Member
  • Posts: 438
  • Thank you received: 53
  • Karma: 15
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
Last Edit: 07 Dec 2016 16:48 by MorganL.
The administrator has disabled public write access.

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

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 987
  • Karma: 140
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 administrator has disabled public write access.
The following user(s) said Thank You: MorganL

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

  • MorganL
  • MorganL's Avatar
  • Offline
  • Platinum Member
  • Posts: 438
  • Thank you received: 53
  • Karma: 15
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
Last Edit: 07 Dec 2016 21:52 by MorganL.
The administrator has disabled public write access.
The following user(s) said Thank You: jonathanbell

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

  • MorganL
  • MorganL's Avatar
  • Offline
  • Platinum Member
  • Posts: 438
  • Thank you received: 53
  • Karma: 15
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
The administrator has disabled public write access.

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

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 987
  • Karma: 140
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 administrator has disabled public write access.
The following user(s) said Thank You: MorganL

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

  • MorganL
  • MorganL's Avatar
  • Offline
  • Platinum Member
  • Posts: 438
  • Thank you received: 53
  • Karma: 15
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
The administrator has disabled public write access.

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

  • MorganL
  • MorganL's Avatar
  • Offline
  • Platinum Member
  • Posts: 438
  • Thank you received: 53
  • Karma: 15
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
The administrator has disabled public write access.

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

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

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

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

Thanks!
Last Edit: 12 Dec 2016 15:26 by liubov.
The administrator has disabled public write access.

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

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 987
  • Karma: 140
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
The administrator has disabled public write access.

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

  • liubov
  • liubov's Avatar
  • Offline
  • Elite Member
  • (=) 10 mn and it's ready!
  • Posts: 279
  • Thank you received: 36
  • Karma: 22
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
Last Edit: 12 Dec 2016 17:32 by liubov.
The administrator has disabled public write access.
The following user(s) said Thank You: admin

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

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 987
  • Karma: 140
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 administrator has disabled public write access.
The following user(s) said Thank You: Romkabouter

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

  • liubov
  • liubov's Avatar
  • Offline
  • Elite Member
  • (=) 10 mn and it's ready!
  • Posts: 279
  • Thank you received: 36
  • Karma: 22
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!
The administrator has disabled public write access.

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

  • MorganL
  • MorganL's Avatar
  • Offline
  • Platinum Member
  • Posts: 438
  • Thank you received: 53
  • Karma: 15
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
The administrator has disabled public write access.

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

  • jonathanbell
  • jonathanbell's Avatar
  • Offline
  • Premium Member
  • Posts: 147
  • Thank you received: 5
  • Karma: 1
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?
Last Edit: 05 Jul 2017 23:23 by jonathanbell. Reason: Spelling mistake
The administrator has disabled public write access.
  • Page:
  • 1
  • 2
Time to create page: 0.093 seconds

Get Started