arrow-left arrow-right brightness-2 chevron-left chevron-right circle-half-full facebook-box facebook loader magnify menu-down rss-box star twitter-box twitter white-balance-sunny window-close
Propel / Pager / Datagrid
1 min read

Propel / Pager / Datagrid

Because we are using propel in most of our larger projects, it’s very common we need a datagrid for the listing of the objects. A year ago we made a datagrid with the most important features combined with an ajax approach (sorting, filtering…), for the ajax functionality we wrote our own javascript function calls, what led to alot of unmanageable code, both javascript and php.

As time moved on, this loading of the datagrid became slower and slower (due to increasing objects, about 9000 records with multiple joined tables). This was mainly because the old datagrid first loaded all objects, and then sorted the entire array by the columns as defined by the user….don’t tell me..i know ! This is a bad approach, that means all records get looped, and if you are using propel that would mean for each of those 9000+ records an object is created…that’s crazy…(it has some advantages though)…

So now i finally found some time to do a total rewrite of this datagrid, combined with the power of the propel pager, propel criteria & the php/ajax framework xajax, i came up, faster then expected, with a powerfull scalable datagrid that only loads the visible records. All switchpages, sorting & filters call a corresponding ajax function. These functions change the criteria in the object and reload the datagrid. I’ll elaborate on this later, by showing you some code and perhaps an online example.