#1 Merged at ca34fda
Repository
bgurvich
Branch
master
Repository
vuleticd
Branch
master
Author
  1. Boris Gurvich
Reviewers
Description

Known remaining issues:

  • The personalized filter value is not showing after reloading the grid page. This is a core bug, affecting 3rd party customizations, which requires events cleanup and refactoring.

Please update the core with latest commit, and more commits are pending for the filter value issue and general cleanup.

Comments (1)

  1. Dragan Vuletic repo owner

    Yep, that works with single gridView event observed. I actually initially tried to do the same thing with gridView, but for some reason I couldn't achieve ORM part. I though you refereed to FCom_Core_View_BackboneGrid::getGridConfigData:initORM event in your previous comment, and that didn't do the trick :-)

    New SQL also fixes the pagination issue, but I can't say I like the resulting SQL when filter is executed.

    Maybe it would be good idea to implement this counting problem in BORM->paginate(), something like code below. Basically something that will perform count() in different way if groping was detected. Essentially it's normal MySQL behavior to change the COUNT result if query contains grouping, right ? Change on BORM will make possible for developers to write orm customization is standard fashion and even if they use grouping application will correctly count the results. From what I was able to test so far, that kind of change in BORM will return correct pagination values with my original ORM code. There may be other problems that I've missed.

    if ( empty( $s[ 'c' ] ) ) {
                $cntOrm = clone $this; // clone ORM to count
    
                $cntQuery = $this->as_sql(false);  /* added attribute, defaults to true, to prevent _build_where() from setting $this->_values */
                $cntFilters = $this->_build_values(); /* added function to retrieve values from $this->_where_conditions in case as_sql() with false */
                /* Change the way we calculate count if grouping is detected in query */
                if ( count($this->_group_by) ) {
                    $s[ 'c' ] = BORM::i()->raw_query( "SELECT COUNT(*) AS count FROM ($cntQuery) AS cntCount", $cntFilters )->find_one()->count;
                } else {         
                    $s[ 'c' ] = $cntOrm->count(); // total row count
                }
    
                unset( $cntOrm, $cntQuery, $cntFilters ); // free mem
            }