Adding Columns to Existing Grid in Kinetic

In many cases, it might not be!

There appear to be three main ways to add columns to a grid:

  1. The data is already in the set: just add the column… but if the fields aren’t already there, then no luck, right?

  2. Create a BAQ with all the columns, plus the added columns, and basically make it from scratch … but this sometimes doesn’t play nice if it needs to interact with other elements on the screen.

  3. Some finesse with a BAQ and some events to hack it together in the UI. (Thank you, @hmwillett!)How To: Adding Columns to Existing Kinetic Grid … but sometimes the events don’t fire when expected, or there are apparently no appropriate events to use.

So what if you could just add the fields to the dataset that is already coming back?
It turns out that you can!

We hired a consultant for help with this … ridiculous. He showed us that it can be really simple.

Step 1: Identify the BO method that is used to populate your grid
In this case, it was ARInvoice.GetRowsCustomerTracker

Step 2: Create a Post-processing directive and add the field to each row of the result dataset
Here’s the code we wrote:


If there are any rows, I grab the additional fields from the database up front in a single query (along with the key fields so I can match the data to the row it belongs in). Then for each row in the dataset, add the new field (or fields). You can see here that I have added UD Field Character01 and gave it the name “ARCode” - you can name it whatever you want (stick to alphanumerics, of course).

Step 3: Add the field to the grid columns.
Use the field name you gave it in your code - ARCode in this case.
image

That’s it.
image

Obviously, not every solution fits every situation, but I’ve customized several grids since learning this method two days ago - instead of fighting with events and remaking whole sections of screens. If you can, use what is already there!

16 Likes

That is cool. I’ll have to try it.

Thanks!

Joe

So, for Kinetic, this is very nice… but I would suspect this same method could be used for Classic, but there would need to be some code added to a Classic Customization to add the new column data to an EXISTING List Grid.
Any insight on how to do that?

Ha, if you’d have searched better… I already shared that :rofl:

Unfortunately not. The data goes through a merge in the client and is lost.

2 Likes

You could pass the extra data down in the call context, and merge it yourself in the client.

There are examples of adding fields to grids somewhere.

I think you can add to the epiDataViews as well, but I’m not sure on that one.

1 Like

Yes, I’ve seen some of them… just nothing elegant… sorry, I prefer solutions that are obvious to future me (and future users) and not a cobbled mess strung together with duct tape and string.
I’ve done this before, I’ve just not liked how it was done and so everytime I go to do it again I look around for a better way.
Thanks!

1 Like

Now that I think of it, that would probably break something, so don’t do that even if you can lol.

3 Likes

On a serious note, you could bring down the extra fields as json in a ud field.
That way it’s more obvious.

Then in an after adapter method, drop the data in your own epiDataView, and do some grid manipulation or maybe a foreign key view.

1 Like

Now that I know it, I see it everywhere! :clown_face:

1 Like

Very helpful, thank you. Works great!

@Rick_Bird I know this is old, but if you add a field to the schema it is added to the list view epimagically unless you check hidden by default. And it still works in Kinetic.

1 Like

This worked like a charm. Thank you!

1 Like

We just implemented this on one of our screens, and it’s great, BUT… we’re having an issue when trying to SORT the grid on the new field that we added. Have you run into any related errors?

We added a custom field, ParentSupplier, onto the grid. The data comes in, but when sorting, we get an error message – Invalid Column Name ‘ParentSupplier’, and it seems like it’s because it’s going back to query the DB with this where clause.

image

1 Like

I had not run into that scenario! and it’s good to bring it into the light.

The first thing that comes to mind is to intercept the GetRows call with a pre-processing BPM to change the whereClauseVendor value to something valid - if there’s some value to actually sort by that’s similar to your added field

Or maybe
Intercept in a pre-processing BPM
if (whereClauseVendor == "By+ParentSupplier")
then set some BPM context value, clear whereClauseVendor, and enable post processing
Then in Post, sort by that value before the dataset is returned
You’ll have to pick up the whereClauseVendor value for when it’s sorting descending, too, and handle that scenario similarly

The export to excel function will not include the added column is a limitation I just discovered. I can’t think of a way to make this happen.

3 Likes