Hi all,
I’m new to GC Enterprise 3.x with CI4, but have a history with GC 1.x and CI3 for a while now.
In working through the conversion of the code to the newer versions, I’ve come across a few questions, and hopefully straightforward to work out…
- In the older GC software, I could define Column Callbacks for “virtual” columns, and those columns would be sortable/searchable in the datagrid. It appears that in GC 3, that is no longer possible. The only way I’ve figured out how to make this work is to do the ColumnCallback and also mapColumn for each of those “virtual” columns to one in the table. This made the info appear in the datagrid, but the sorting is tied to the column it is mapped to.
Ultimately, these extra data fields are just read-only data from another table. Consider the situation where the table we’re editing has a user# entry, and that refers to anther table where I get the user first/middle/last name components. It isn’t that I need to edit those name fields, but having them on the datagrid makes it way easier for someone to come along and know which entry to edit.
This worked great in GC 1, but doesn’t seem to be there in GC 3 to the same capacity.
- I’m looking to be able to create “virtual” data fields for the insert/update/read fields. In this situation, the table contains a CountyID field (numeric). That is a pointer to another table that maps Counties to States, and then another table that maps States to Countries.
I’m looking to be able to define the State and Country fields, so that I can use pulldowns in the edit form, where you would first select the country, which in turn populates the State pulldown, and then select the State, which would populate the County pulldown, and then you select the County. (a numeric value – and the only value that is actually saved to the table).
Again, something I could do with Edit field callbacks in GC1, but in GC3, this creates an error with an unknown data type. I tried setting the field data type for those additional fields, but it didn’t resolve those errors.
I believe in both of the situations above, I could probably extend/customize the Model to allow for it to grab the extra columns from the related tables, and make it work, though not perfectly ideal. However, being newer to both CI4 and GC3.x, I’m struggling to figure out the best way to do this. Ideally I’d extend the GC3 Model so that I only need to modify the appropriate functions.
It appears, to me, that the GC3 Model is at:
app/Libraries/GroceryCrudEnterprise/grocery-crud/enterprise/src/GroceryCrud/Core/Model.php
However, what would the best practice for where to locate my version of the model?
app/Models/* ?
And if so, what would be the appropriate way to extend the model in that location (trying to work through the namespace issues correctly). The GC3 documents highlight this for CI3, which is fairly different from CI4. I understand the class functions, once the path and namespace/use/extends is all setup appropriately.
So a couple of wishlist items (unless I missed them on the documentation somewhere), and a HowTo (hopefully somewhat simple)
Thanks much in advance for the help/info.
Erick