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

TOPIC:

Ajax Filters Back-end initialisation (with fix) 17 Nov 2012 13:25 #5435

Hello,

I noticed that when using ajax filters (in my case grouped), that they don't initialise properly after they have been used. For example I had a drop down with people names and when I filtered on one of them, the filter does work but the drop down is not initialised to the value selected.

After looking at the generated source code I think I found the issue. In my example 'person' is the list view and 'personitem' is the item view. When it tries to get the state variable, there are actually two issues. One of them is that the wrong model is accessed (it gets the item model and the state variable should be stored in the list model). The other thing is that the filter does not exists yet in the filters array and should be created.

In my example this code for the view.html.php for my list view was originally:
$model_person_id = JModel::getInstance('personitem', 'SlmModel');   
$this->filters['person_id']->values = array(
                $model->getState("filter.person_id"),
            );

I changed this to:
$model_person_id = $this->getModel();  	// get it's own model (the list view for persons)
$this->filters['person_id'] = new stdClass();	// create a new entry in the filter array
$this->filters['person_id']->values = array(
       $model->getState("filter.person_id"),
);

And now it all works. So I will just need to do this for all other views as well where an ajax filter is used.

I don't know if this is an issue I only experienced or whether others had this as well. If so, you can use the solution above. If it happens always it will probably need to be fixed in the generation code of Cook.

Hope it will help others.

Kind regards,

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

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

Re: Ajax Filters Back-end initialisation (with fix) 17 Nov 2012 14:06 #5436

Just noted that the first line in the changes (the one with getModel())) is not required. That was a left over of some tests. So the code should be:
$this->filters['person_id'] = new stdClass();	// create a new entry in the filter array
$this->filters['person_id']->values = array(
       $model->getState("filter.person_id"),
);
The following user(s) said Thank You: JoomGuy

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

Re: Ajax Filters Back-end initialisation (with fix) 21 Nov 2012 10:12 #5549

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 986
Welcome to the community.

Thank you very much for this catch.
It is very nive becaue I am currently rewriting there.

Something you missed to say is that to BIG issue with filters is else ;-)
Look on that example.

Continent, Country, City

If you filter Cities on Continents
The problem is the select list is not initialized with a Continent list. For the moment you must use the groups.

If further version, you will be able to REALLY filter on foreign values with incredible possibilities.
This is why I am less responsive in the forum, it is because the filters have to be rewritten from the begining.
As well as the TASKS I will do after.

Once V2.0 will be released, Cook will fly in higher pics of dev and promise I will clean all issues even the smallest remaining.
Coding is now a piece of cake

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

Re: Ajax Filters Back-end initialisation (with fix) 21 Nov 2012 11:14 #5556

Hello,

Thank you very much for your reply.
Currently I am used groups for multiple filters and that seems to work fine (with the mentioned workaround).

I will look forward to the revamped filtering system. I noticed at the moment it does not always work properly from the cook interface. It seems more like a performance/memory issue, as when it does not work for me, when I try a bit later it does work. What happens when it does not work is that I am able to drag the field I want for the lookup from the fields list, but it will only generate a text field for the ID of the table.

Keep up the good work!

Kind regards,

Misha

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

Re: Ajax Filters Back-end initialisation (with fix) 21 Nov 2012 16:07 #5577

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 986
You must open the node, and darg a sub element.
Coding is now a piece of cake

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

Re: Ajax Filters Back-end initialisation (with fix) 22 Nov 2012 08:12 #5605

I know that. But sometimes the node does not open, or sometimes it does open but when I drag a particular field from the opened node it seems like it worked but when I open the options after dragging the field to the fly or to the grid it is linked to the id field.

As mentioned before this happens not all the time, just sometimes, so that is why I thought it might be a memory or performance issue (I have a lot of tables in the component)

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

  • Page:
  • 1
Time to create page: 0.069 seconds

Freakin' Awesome!!! J-Cook is simply awesome - whether you're a highly experienced developer or complete novice whether you're building a small inventory component or a complete community solution! The beauty comes from a fast slick and reliable platform that readily provides developers with everything they'll need to build the backbone of a solid and secure component with wizards for authoring access publishing aliasing created/modified by dates... you name it COOK provides it! J-Cook really surpasses all of the 'competition' as far as MVC tools are concerned! Try love it and get cooking!
learnthrusong (JED)
          

Get Started