Select2 multi-select in list filtering ?

lcollong

FabriKant d'applications web
Hi,

A/ There is an option to turn on "choosen" dropdown for the list filtering. But it does not trigger for the multi-select option (screenshots).

B/ I have modified the template to display the number of lines (total number of rows) that a given filter setup show up on the top of the list. Of course, it does not work if using Ajax navigation. Apparently, the json sent back to the browser contains the right number. Is there some functions/helpers I can use to write some js to update my own figure ? Could you point me to some file/template from which I could start to add my own functionnality ? BTW is there a way to know if any filtering is applied ? I'd like to show a different sentence in case of showing all records.

C/ Is filter as popup list setup supposed to work together with ajax navigation ? I'm experiencing strange behaviors when both are enabled.

This can be seen and tested on the site "NB" in "mySites" (menu : BASES >> LISTE DES TERRAINS). Not the "old" one, the last one, ie : index.php?option=com_fabrik&view=list&listid=64&calculations=0&resetfilters=0&Itemid=259

Thanks.
 

Attachments

  • Capture1.JPG
    Capture1.JPG
    32.6 KB · Views: 65
  • Capture2.JPG
    Capture2.JPG
    24 KB · Views: 64
  • Capture3.JPG
    Capture3.JPG
    33 KB · Views: 62
B/ I have modified the template to display the number of lines (total number of rows) that a given filter setup show up on the top of the list. Of course, it does not work if using Ajax navigation. Apparently, the json sent back to the browser contains the right number. Is there some functions/helpers I can use to write some js to update my own figure ? Could you point me to some file/template from which I could start to add my own functionnality ?

We fire a Fabrik event, fabrik.list.submit.ajax.complete, after the list is redisplayed with the filtered data. So a list_X.js file, with ...

JavaScript:
requirejs(['fab/fabrik', function () {
   Fabrik.addEvent('fabrik.list.submit.ajax.complete', function(list, json) {
      // your code here
   });
});

I suspect the approach you would want to take is to embed your number of rows in a div, with an ID or class you can then select and update the content of in your JS.

BTW is there a way to know if any filtering is applied ? I'd like to show a different sentence in case of showing all records.

Not that I can think of, no.

C/ Is filter as popup list setup supposed to work together with ajax navigation ? I'm experiencing strange behaviors when both are enabled.

Don't know, never tried it. That was something Rob wrote a while back, and it's not a feature I ever use. I guess it either works or it doesn't. If it doesn't, then it's broken. If it's broken, I'll put it on my long list of Shit That Needs Fixing.

-- hugh[/quote]
 
However, could you give your feedback on the first item of my post ?
A/ There is an option to turn on "choosen" dropdown for the list filtering. But it does not trigger for the multi-select option (screenshots).
 
Try this:

https://github.com/Fabrik/fabrik/commit/5e069547c5ab0f65face8538c48e803fbb6ba301

The AJAX stuff shouldn't be too hard, maybe 1 line inside that wrapper I gave you. If you wrap you number of lines in your template like ...

Code:
<span id="my_number_of_lines">No of lines: 10</span>

(obviously you wouldn't hard code "10", but that's just an example)

Then in your JS, where I put "// your code here", you just need to do ...

jQuery('#my_number_of_lines').html('No of lines: ' + json.data[0].length);

Might need to sanity check and make sure data[0] exists, but that's the guts of it.

-- hugh
 
Thanks Hugh for the multiselect path. Much better this way.

For the AJAX stuff, for now I'm finishing the site without ajax navigation (nor ajaxified links).
After that, I'll try to switch to Ajax navigation and see if everything is working except the "total" block. But I suspect problems. Maybe coming from Gantry5. I'll do tests and keep you inform.
Finally, if every thing is fine, I'll implement your recommendations for making the "total stuff" working under Ajax.
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top