or_where seems to break edit refresh and create strange behavior

or_where seems to break edit refresh and create strange behavior

bpitonibpitoni Posts: 21Questions: 7Answers: 2
edited August 2017 in Free community support

Just posting this in case others have a similar issue.

Normally a datatable when edited has a default refresh behavior (the row turns yellow briefly then reflects the change), but when using an "or_where" clause, my table did not refresh.

Also, when adding new records, it seemed to insert a duplicate of the first row, instead of the data entered.

To fix this, Allan suggested I replace this:

->where( function ($q) {
              $q->where('campus','MC')
                ->or_where('campus', 'both');
  } ) 

with this:

->where( function ($q) {
        $q->where_group( function ( $q2 ) {
            $q2
                ->where('campus','MC')
                ->or_where('campus', 'both');
         } );
    } )  

This fixed the issue for me! Hope it helps someone else!

-Brenda

This question has an accepted answers - jump to answer

Answers

  • bpitonibpitoni Posts: 21Questions: 7Answers: 2
    Answer ✓

    This issue is resolved.

  • gandersonganderson Posts: 3Questions: 0Answers: 0

    Thanks bpitoni, that did indeed solve a related issue for me.

  • Loren MaxwellLoren Maxwell Posts: 406Questions: 99Answers: 10

    bpitoni, this was indeed the fix I needed as well!

    Allan, any chance this can make it into the documentation?

  • allanallan Posts: 63,480Questions: 1Answers: 10,467 Site admin

    Sounds like a sensible idea to me - I'll add in information about it.

    Thanks,
    Allan

This discussion has been closed.