Add related field to TV

If you're a new user of AppGini, feel free to ask general usage questions, or look for answers here.
Post Reply
DevGiu
AppGini Super Hero
AppGini Super Hero
Posts: 151
Joined: 2016-05-27 09:08

Add related field to TV

Post by DevGiu » 2016-08-21 06:45

Some idea how to add a new field to TV?
I want to show more information in TV and don't know exactly how to do it (without modifying directly the file, to avoid overwrite).

I'm trying modifying datalist without success.

Attached there are an image showing the way I'm trying to do. In this sample, I just try to add a field from an existing relationship in this query (the id of a lookup field)
Attachments
IMG_20160821_083653-800x396.jpg
IMG_20160821_083653-800x396.jpg (57.4 KiB) Viewed 8702 times
/Giuseppe
Professional Outsourcing Services

grimblefritz
AppGini Super Hero
AppGini Super Hero
Posts: 336
Joined: 2015-12-23 16:52

Re: Add related field to TV

Post by grimblefritz » 2016-08-21 13:32

The simplest way is to add it as another field in the table. Readonly, of course. Show it in TV, hide it in DV if necessary.

That's the easy way... until Ahmad works out how to give us SQL views, or support for "virtual fields" (calculations, lookup values, etc.)

DevGiu
AppGini Super Hero
AppGini Super Hero
Posts: 151
Joined: 2016-05-27 09:08

Re: Add related field to TV

Post by DevGiu » 2016-08-21 14:42

I think should be some way to do It with Code.

I know you can do it in the way you explain, but I don't want to add "unused" fields to my database
/Giuseppe
Professional Outsourcing Services

grimblefritz
AppGini Super Hero
AppGini Super Hero
Posts: 336
Joined: 2015-12-23 16:52

Re: Add related field to TV

Post by grimblefritz » 2016-08-21 15:34

I think you will have to modify both the template and datalist. Which creates maintenance problems.

I would add the extra fields. I doubt any AppGini solution is so large or complex that the execution and storage impact is significant. It's not "proper", but if it works, that's what matters.

But, maybe that's just me :)

Noha Eshra
Moderator
Posts: 82
Joined: 2013-11-11 19:21

Re: Add related field to TV

Post by Noha Eshra » 2016-08-24 18:10

It will take us some time to try this code and try to reproduce this issue and debug this code.

Meanwhile try use the tablename_init hook to modify the table view query.

DevGiu
AppGini Super Hero
AppGini Super Hero
Posts: 151
Joined: 2016-05-27 09:08

Re: Add related field to TV

Post by DevGiu » 2016-08-24 18:17

This is what I'm trying to do and asking how to do it
/Giuseppe
Professional Outsourcing Services

grimblefritz
AppGini Super Hero
AppGini Super Hero
Posts: 336
Joined: 2015-12-23 16:52

Re: Add related field to TV

Post by grimblefritz » 2016-08-24 18:48

Noha,

I think what would help is if there were a tablename_line_item() function that was called prior to rendering each line of a table view. That might facilitate adding/altering fields in the table view.

Right, DevGiu?

Noha Eshra
Moderator
Posts: 82
Joined: 2013-11-11 19:21

Re: Add related field to TV

Post by Noha Eshra » 2016-08-24 19:44

Please check lecture 28 in the online course for how to do it.
https://www.udemy.com/customizing-appgi ... ode=TENOFF

DevGiu
AppGini Super Hero
AppGini Super Hero
Posts: 151
Joined: 2016-05-27 09:08

Re: Add related field to TV

Post by DevGiu » 2016-08-24 20:03

Noha Eshra wrote:Please check lecture 28 in the online course for how to do it.
https://www.udemy.com/customizing-appgi ... ode=TENOFF
But this is detail view. I'm talking on table view. I just want to add a new field to table view. calculated, a field coming from other table, a fixed value, whatever, and add this new column in table view in code from hooks.

Example. I have a table view for table customers. I want to add a new field showing the total amount of bills paid by this customer, but I don't want to add this field on appgini desktop app, I mean , I want to do it on every record, calculate this value and show on a new column

Grimblefritz. Could be interesting. Some like tableview_onrecord, virtual fields on appgini, but I need to know how to do this now, not in next versions :P
/Giuseppe
Professional Outsourcing Services

grimblefritz
AppGini Super Hero
AppGini Super Hero
Posts: 336
Joined: 2015-12-23 16:52

Re: Add related field to TV

Post by grimblefritz » 2016-08-25 11:11

Yes, I know you need it now. I was hoping maybe it would help Ahmad and Noha identify where to direct you.

Noha Eshra
Moderator
Posts: 82
Joined: 2013-11-11 19:21

Re: Add related field to TV

Post by Noha Eshra » 2016-08-25 11:25

Actually if you follow the instructions mentioned it will show the field in the table view as long as you didn't choose to hide it in AppGini.
In case you want to hide it in the detail view, you could add jquery code in tablename_dv.js to hide the desired field as explained in the course lecture 25 .

grimblefritz
AppGini Super Hero
AppGini Super Hero
Posts: 336
Joined: 2015-12-23 16:52

Re: Add related field to TV

Post by grimblefritz » 2016-08-25 11:43

Noha,

He's not using fields in the table, but is wanting to add columns to the table view and populate them with data generated outside of AppGini. The techniques in the course do not address this.

DevGiu
AppGini Super Hero
AppGini Super Hero
Posts: 151
Joined: 2016-05-27 09:08

Re: Add related field to TV

Post by DevGiu » 2016-08-25 11:53

Noha Eshra wrote:Actually if you follow the instructions mentioned it will show the field in the table view as long as you didn't choose to hide it in AppGini.
In case you want to hide it in the detail view, you could add jquery code in tablename_dv.js to hide the desired field as explained in the course lecture 25 .
Noha, again, a field not in AppGini. I don't want to AppGini to modify my table structure just because I need to show a value in one place. I saw the course, 28, and the complete course 5 times. But course don't helps on Table View customization.

I want to show a field from other table, related to the actual table being shown, or a fixed value, or whatever, but on a new column, created by code from hooks, but I don't want to modify my database structure.
Another example, I have a billing table, and I have my table view for this table, all ok. Now, for each bill I have to lookup on other table for some value, and return this value on a new column, for every record (not a real example, just to know if if it's a better explanation).

AppGini generation creates columns for the actual table, and/or with lookups to show values from other table, always if this field exists, but this field don't exists and I don't want to exists.

I don't want to create this table because is unnecesary information I just want to show in one place, and I don't want this field in my table.
I don't want to modify template or something like this, because I don't want to be worried if my changes will be override on some code generation from AppGini, for this reason, I want to do it from hooks. It's suppose this can be do it modifying $options datalist, but, how?

On the sample I provided, in the first post, I have a table, with a field with a lookup. For this reason, I have a JOIN in the query. Just to try if it works, I tried, to add a field that actually is related because JOIN, adding this field manually to QueryFieldsTV as Ahmad suggested me, but any new column was shown.
Then, I tried with the steps in next screens (for this reason I have 4 or 5 lines of code, adding the field to different options), and finnally I get a new column on my table_view, but without any value.
/Giuseppe
Professional Outsourcing Services

grimblefritz
AppGini Super Hero
AppGini Super Hero
Posts: 336
Joined: 2015-12-23 16:52

Re: Add related field to TV

Post by grimblefritz » 2016-08-25 12:02

To add to what DevGiu is saying, I would use the same capability.

Example: Consider a table with cost and qty. There is no reason to store total in the database. Instead, in table view, I'd rather a new column for total, which would be populated with cost*qty.

I can already do this for detail view, as (I think it was) Ahmad shared code for how to add "fields" to the DV form.

What we need now, is a similar capability for TV.

Post Reply