Kinetic/AppStudio - Work with grid columns title

I have a need to rename the grid column names dynamically with month like "September”, “October” …

image

Is it possible to rename grid column header programmatically, preferably with variables?

Thanks!

1 Like

I tried {Constant.Month} but it did not work :sob:

Like this:

Any solutions?

1 Like

I’m completely guessing here but can you figure out an event that you might be able to create a custom action on such as when the grid is loaded? Or perhaps the EpiDataView associated to the grid. Can you change the label associated to the columns that way? I’m not sure. I’ve never tried. But I’m interested in this as it has come up before. I’ve always just done something like +1 Month, +2 Months, etc. It got the job done. But wasn’t as pretty.

3 Likes

I’m out of office now but I would try to wrap your thing in double quotes and see if that helps. You can also try the same with any dataview field

1 Like

image

image

I tried single quotes and double quotes, but it did not work.

Mr. Long,

My plan for these queries was to rewrite it in SQL as a view in our non-Epicor db and bring it in as an External BAQ but never got around to it. I was looking into using unpivot rather than pivot but Epicor queries didn’t support it directly in query builder. But it might be possible with some events in the new kinetic layers as Dan suggested.

For context for everyone, currently it was being done in our c# customization layer but we are migrating these to kinetic.

1 Like

Found a solution for this. The key is Property-Set.

Try to find the GUID for the panel card grid. How to find that?

Step 1: Your gridID and GridModel should be same.
image
image

Step 2: Create a dummy button and create onClick event

Step 3: Inside the event, create a condition and put below expression

#trans.epEventService.epObjectManagerSvc.components.find(x => x.id == ‘grdLandingPage’).model.guid# === “”
Here, ‘grdLandingPage’ is your gridID

Step 4: On the condition true side, have a message event to show some text
Step 5: Preview it. Hit the button and find the GUID in console screen.
Step 6: Note down the GUID for the grid

Now the actual solution:
Quite simple, you just put property-set after form load or wherever you want and set something like below,

image
Here, you have to paste the copied GUID in both places, then

image
Here, [0] refers to your column position

Happy epicoring…! :wink:

5 Likes

It’s late, I know, but for giggles and grins, here’s what worked for me.

You use the field name for the column to assign the value to the column title.

For the real work, I stuffed the month names into fields on TransView and assigned from there.

new Date(new Date().setMonth(new Date().getMonth() - 12)).toLocaleString(‘default’, { month: ‘long’ })

For what it’s worth.

Joe

5 Likes

Thanks for sharing. this is just tangential commentary but…

Been trying to wrap my head around the columns, columns, columns, situation and think I’ve come up with something of an idea… just putting this here for my own sake

columns have two properties field and title and we need a third say ‘role’ or ‘id’.

BEFORE (what we have today, grid column id assumed to equal field)

gridModel.columns = {
  Part_PartNum: { field: "Part_PartNum", title: "Part #" },
  Part_Description: { field: "Part_Description", title: "Description" },
  PartLot_LotNum: { field: "PartLot_LotNum", title: "Lot" }
};

AFTER (defaults to field, but optionally abstracts the column away from both field and title)

gridModel.columns = {
  PartNum: { field: "Part_PartNum", title: "Part #" },
  Description: { field: "Part_Description", title: "Description" },
  LotNum: { field: "PartLot_LotNum", title: "Lot" }
};

This would make dynamic grids, providers, views (especially based on BAQs) work better and provide potential for UI expressions that eval properly on dynamic dataviews.

Just a thought.

Would this work similarly for year? Say I wanted to go back 5 years with my data. Should the expression read: new Date(new Date().setYear(new Date().getYear() - 5)).toLocaleString(‘default’, { year: ‘long’ })?

I’m struggling my way through this. How do I get the GUID for my grid? I think if I could get that, I’d be up and running. I actually have my own post here if you want to weigh in there… Adding Month/Year to Column Title in BAQ Grid

Any success for month and year combinations?

I meant to follow up on this. Yes - I got it to work. So I copied the strategy shown above. There are some bits that I wish were more detailed as I had to figure some stuff out… but basically, I created 12 columns in TransView. Then I set each column’s value using a row-update widget. Then I set the properties of the columns in the grid I want to rename to the values of those TransView columns.

I ended up creating an event with a trigger on the grid control creation. This event then fires the two custom events I created that set the titles to my TransView columns and then set the properties of the columns in the grid.

For whatever reason, even though it lets you set multiple columns within a single row-update widget, it won’t work. So you have to make a new row-update widget for each column to update. It ends up looking like this:


Below is what I used in the expression in the row-update for each month that I wanted to do.

new Date(new Date().setMonth(new Date().getMonth())).toLocaleString('default', { month: 'short' }) + '-' + new Date(new Date().setMonth(new Date().getMonth())).toLocaleString('default', { year: '2-digit' })

Then for each month prior (or you could do it looking forward also), I subtract my months from current date like this:

new Date(new Date().setMonth(new Date().getMonth() - 1)).toLocaleString('default', { month: 'short' }) + '-' + new Date(new Date().setMonth(new Date().getMonth() - 1)).toLocaleString('default', { year: '2-digit' })

Within the property-set widget, I was able to do 12 properties within the one widget so I was able to set each column’s name like below:


gridLandingPage is the ID of the grid control. gridModel is the ID of the GridModel, which is under the Data group inside of the grid control properties. It’s shown in the posts above but until you wrap your head around it, it’s not obvious. I spent way more time than I care to admit getting that figured out.

4 Likes