This topic is locked
[SOLVED]

 Programatic Filter Control

11/2/2017 9:03:14 AM
PHPRunner General questions
S
Scrolin author

I have an application for the entry of competition scores. Occasionally (well a bit more often than that) it is necessary to use additional filters to narrow down the score record to be updated, either because the competitor number is illegible, or just plain wrong. It is tedious and time consuming to have to clear these filters manually on return from the score entry screen as entry speed is important due to the volume of scores to be entered.
Is it possible to add code to the afterInlineEdit event to clear some of these filters. I've been trying various combinations of the following but without success

var id = "#clearLink" + filtername;

$(id).click();

[/size]

and

var id = "#clearLink
" + filtername;

$("[id^=" + id + "]").click();

[/size]
etc....
For maintainability, it would be useful to be able to step through the filters programatically rather than specify those to be cleared explicitly. In interface akin to the search controller would be useful.
In a similar vein, and for the same reasons, I want to set the focus on the Competitor number search field on return from the score entry popup, and to remove any other search criteria. I've tried the following in the afterInlineEdit which successfully removes the additional search criteria but fails to set the focus. Any tip?

var srch = pageObj.getSearchController();

var searchfields = srch.getSearchFields();

var x;

var field;

var name;

var ctrl;

for (x in searchfields){

field=searchfields[x];

name = field.getName();

if (name== 'CompNo'){

ctrl = field.getControl();

ctrl.setValue("");

ctrl.setFocus();

}

else {

field.remove();

}

}

[/size]
PS Happy to split this 2nd part into a separate topic if it helps

S
Scrolin author 11/4/2017

I think I'm getting nearer, but am not there yet...
I've tracked down (hacked?) the properties of the search controller for the filters. My code in the afterInLineEdit event now does the following



var srch = pageObj.getSearchController();

for (x in srch.filterControls){

fltr=srch.filterControls[x];

if ((fltr.fieldName == 'Surname') || (fltr.fieldName == 'FirstName')){

if (fltr.filtered){

// <<<<< what method should I call here? >>>>>

}

}

}


If anyone can advise what method call should replace the comment that will crack it.
On setting the focus in the search field, I've found that it works fine when done in the Javascript OnLoad event (ie when the list page is first loaded), but not in the afterInLineEdit event. When the filter reset above works the list page should reload, but when no filters are to be cleared I would still want the setFocus to work.Is there a later event I could use?

S
Scrolin author 11/7/2017

This seems to do the trick.



var srch = pageObj.getSearchController();

for (x in srch.filterControls){

fltr=srch.filterControls[x];

if ((fltr.fieldName == 'Surname') || (fltr.fieldName == 'FirstName')){

if (fltr.filtered){

var clear_filter = '.filter-clear-' + fltr.fieldName;

$(clear_filter).click();

}

}

}


This is very nearly solved (though I'd like to have confirmation that I won't fall down some other hole following a PHPrunner upgrade).
All that's left is setting the focus in the competitor number search field following score entry with no additional filters. As I predicted, when the filter reset above fires, the list page does reload, but when no filters are to be cleared I would still want the setFocus to work.

Is there a later event I can use, or should I work out how to fire the showall link in the search panel (I think that's calling the showAllSubmit() method of the search controller)?

S
Scrolin author 11/10/2017

I think I've found why calling setFocus() in the afterInLineEdit doesn't work. Tracing the setFocus() call I found a test on the 'hidden' property which held true and prevented the setting of focus. Presumably, the popup still exists and thus the controls in the list page are deemed to be hidden.

All that's left is setting the focus in the competitor number search field following score entry with no additional filters. As I predicted, when the filter reset above fires, the list page does reload, but when no filters are to be cleared I would still want the setFocus to work.

Is there a later event I can use, or should I work out how to fire the showall link in the search panel (I think that's calling the showAllSubmit() method of the search controller)?


Having set the focus to the Search competitor number field on loading the page, either calling the showAllSubmit() method of the search controller or calling location.reload() seem to be work in the afterInLineEdit event. Not sure which is better... advice please.
Either way I'm setting this to solved though I feel a little unsafe as I'm not using publicised interfaces for the filter controls. Is there a definitive list of objects, properties and methods? It would be a very useful addition to the documentation.