Calc element value and icon replacement disappear after ajax filter

juuser

Well-Known Member
Hi,

Problem seems to be similar as in this earlier thread:
http://fabrikar.com/forums/index.ph...alue-disappears-after-ajax-list-filter.40634/

After filtering the table, calc element value disappears after 5-15 second. On another field calc element value which is replaced with icons, changes to value also after 5-15 seconds.

It can be seen on my test site. List is located in top horizontal menu "Tooted->Reklamastioonid ja mittevastavused". Elements that have problems are "Vastuse t?htaeg" and "Tegev. l?pet.?"

In backend element id-s are 4959 (vastuse_tahtaeg_varv) and 1982 (tegevused_lopetatud)

Thanks for your help :)
Martin
 
OK, this is a tough one.

I think the problem lies somewhere in the difference in formatting of some element data between when data gets submitted, and when it gets read from the database. During the list AJAX update, we're providing data for the {placeholder} substitutions read from the database, without running it through the (very expensive) element rendering process. While this isn't usually a problem, I think for some things (like possibly dates) this may cause problems with calc code, which expects one format and gets another. So where a calc may work on submit or form display, it might fail during an list AJAX update.

I tried debugging your two failing calcs, but it's pretty much impossible just because of the sheer number of calcs in that list.

Which really leaves us with a couple of options, both of which involve changes to Fabrik.

1) Make the list AJAX update obey the "calc on save only" setting, so if that is set to Yes, we don't call the list AJAX update after filtering.

2) Add Yet Another Option to the calc to specifically disable list AJAX updating.

Which one would work better for you? Main issue is whether you need to calc on initial list display or not.

-- hugh
 
Thanks for digging into this! Actually for the first element i need the calc element to calculate on initial list display. It is a due date field
which turns red when the date is past today etc. So i guess that leaves option no 1 ?

BR,
Martin
 
As a test can you try this. Edit ./plugins/fabrik_element/calc/calc.php, around line 720, change this:

PHP:
        $opts->doListUpdate = $params->get('calc_on_save_only', '1') ;

... to this ...

PHP:
        $opts->doListUpdate = $params->get('calc_on_save_only', '1') == '0' && $params->get('calc_ajax', '0') == '1';

... and make sure the "AJAX calc" is set to No. If that does what you need, I'll add a seperate "AJAX List calc" option and use that.

-- hugh
 
Hi Hugh,

I don't know am i blind, but i can't find even similar phrase in the calc.php file in the mentioned folder. Also checked from latest Github, but sill nothing :(

BR,
Martin
 
Ooops my bad, that line hadn't made it in to github, it was from when I was playing with this stuff before.

So put that whole line immediately before:

PHP:
        $opts = json_encode($opts);

.... in elementListJavascript().

-- hugh
 
Thanks! Tried this, but the problem is still the same. Also cleared Joomla and browser caches.

Just to be sure I edited the file correctly, I copy the code here:

Code:
  public function elementListJavascript()
   {
     $params = $this->getParams();
     $id = $this->getHTMLId();
     $list = $this->getlistModel()->getTable();
     $opts = new stdClass;
     $opts->listid = $list->id;
     $opts->listRef = 'list_' . $this->getlistModel()->getRenderContext();
     $opts->formid = $this->getFormModel()->getId();
     $opts->elid = $this->getElement()->id;
     $opts->doListUpdate = $params->get('calc_on_save_only', '1') == '0' && $params->get('calc_ajax', '0') == '1';
     $opts = json_encode($opts);

     return "new FbCalcList('$id', $opts);\n";
   }
 
EDIT: Sorry for rushing. Was very tired last night and forgot that i had turned list ajaxify to "no", so unfortunately still the same problem :(


You're right. Element ajax calc was set to "Yes" (mixed it with list ajax setting).:oops: Changed to "No" and now seems to work fine. Thanks!
 
Last edited:
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top