Posted: September 19, 2023 at 12:58 pm
I am looking to add a few additional columns to the Transaction page in Event Espresso 4 and have an additional column be sortable and all columns to be searchable.
So far I have been able to add those columns and their values. However, I am having issues with getting both sorting and searching those new columns and values.
Here is the current version of my code
I was referenced to https://gist.github.com/Pebblo/88f2a0a9213c716e4886a249e7709245
However, I am looking to make adjustments to the Transaction_Admin_Page so I looked for the same filter for the Transaction page but no luck. There doesn’t seem to be a FHEE__Transactions_Admin_Page___get_orderby_for_transactions_query or similar.
The closest filter I could find is
However, when I looked at what was available to alter for order it doesn’t seem like I am in the right place. Here is what is in the $order_by variable.
Maybe I am going down the wrong direction here but yes I am still having issues with both the sort and search of a custom added column on the transaction page. Any help would be appreciated.
I possibly got a little further. I was able to differentiate the requests using the second parameter from the filter. After that I unset the order_by array and instead added a new option for order_by[‘Answer.ANS_value’] => asc/desc
However, I appear to run into an issue where I believe the problem is that the Answer.ANS_value model is not part of the Transaction model so it throws an error.
I tried a few different options both trying to figure out if I can somehow pass the model in the [‘order_by’] array or if there is something to do with the [‘defualt_where_conditions’] but I couldn’t find anything.
I highly recommend you fix the variable names here.
Anywhere you have
Which also means then that
Correct, the problem is that the transaction doesn’t relate to the Answers.
Answers are related to registrations and registrations are related to the transaction.
What you are trying to do here is pretty complex, it may not seem it, but it is. I know I’ve previously posted to you about how our models make things easier and this is an example of just how they do that.
A couple of things to note:
As you on the Transaction page, that run on EEM_Transaction, meaning its looking for values related to the Transaction objects, so in English the above code says:
Set the order_by value to be based on the Answer.ANS_value, sorted ASC/DESC (depending what the request is)
When that’s run on EEM_Transaction is looks for relations related TO the based model (In this case the EEM_Transation)… but you can tell the models where the relation applies by passing a little more information. Answers related to registrations, so tell the model that with:
Which in English:
Set the order_by value to be based on the Answer.ANS_value related to the Registrations, related to this transaction, sorted ASC/DESC
(Its a little easier to read it backwards as ‘related to’ etc.
I can’t say for sure if that will work, I’m going off the top of my head and a quick test with the EEM_Transaction model query using the correct relations above but it should give you more of an idea of what is happening.
That’s great. I have it working with the change you supplied.
However, the next problem I am having is these new columns that I have added do not work for the search functionality on the Transactions page. Do we need to add the new columns to the search somehow?