Greetings, in Strapi 3.1.6 the following lifecycle hook was still triggered, which I used to create a type of “calculated field”, in the admin entity list view (!), i.e. something that is displayed in the pager view (!) as a value determined on-the-fly:
module.exports = {
lifecycles: {
async afterSearch(entries, params) {
console.log("Hello I am the afterSearch hook!");
/* Calculate something on the fly here, for example combine two fields in some algorithmic way */
}
}
}
However, as of 3.6.3, which is the next version I tried after 3.1.6, it seems like that hook is never called any more, at least not when normally paging through the pager.
If you hadn’t heard of the beforeSearch hook, I hadn’t either, until I found this article on strapi.io: Guide to Content Modelling in Strapi
In version 3.1.6, it works to display “calculated data” in the pager, i.e. i can create “virtual columns” that get their data in real time from other columns, or from the outside world even, or a mix of both. In 3.6.3, it shows empty fields only (as the fields in question don’t exist as a real database “cell”) (I have not tried any versions above 3.1.6 and below 3.6.3).
Is this a new caching scheme that avoids round-trips through hooks deliberately? The current admin interface is quite a bit faster and responsive than the 3.1.6 one but if the price is I can’t display the data that I want, I would prefer to turn off this “caching” for that entity type. Possible?
If the afterSearch hook has been renamed to something else, or there is a different, clean way to display on-the-fly calculated cells in the admin pager, LMK! Much appreciated.
System Information
- Strapi Version: 3.6.3
- Operating System: Ubuntu 16
- Database: MongoDB 4.x
- Node Version: 15.14
- NPM Version: 7.16
- Yarn Version: N/A