Adding column to Work Order Inputs grid  Topic is solved

Discussions relating to plugin development, and the Jiwa API.

Adding column to Work Order Inputs grid

Postby DannyC » Thu Jul 02, 2020 6:07 pm

I want to display another an extra column in the work order Inputs grid to show the line total of each input line.
This code adds a column, but I can't work out how to populate it.
Code: Select all
if (JiwaForm is JiwaFinancials.Jiwa.JiwaBillOfMaterialsUI.WorkOrder.WorkOrder)
{
   JiwaFinancials.Jiwa.JiwaBillOfMaterialsUI.WorkOrder.WorkOrder woForm = (JiwaFinancials.Jiwa.JiwaBillOfMaterialsUI.WorkOrder.WorkOrder) JiwaForm;
   woForm.InputsJiwaGrid.AddColumn("LineTotal", new JiwaFinancials.Jiwa.JiwaApplication.JiwaManageGrid.JiwaCurrencyCellType(), "LineTotal",8,false,true,true,true,8,false,false,2,false,false);
}

I don't need the line total to be saved to the database, I just need it as a calculated column to display on screen.

Can you suggest how I could populate it?
User avatar
DannyC
Senpai
Senpai
 
Posts: 636
Joined: Fri Mar 22, 2013 12:23 pm
Topics Solved: 30

Re: Adding column to Work Order Inputs grid

Postby Mike.Sheen » Mon Jul 06, 2020 5:23 pm

As you'd expect - add handlers for when a read is completed, when an item changes and so on and populate the desired cell with the desired value.

I little bit of complexity is involved in that the input items shown on the input items grid is related to the selected stage - but it's just a case of displaying the values when the stage might have changed.

Attached plugin for 7.2.1 demonstrates this.
Attachments
Plugin Add Total Cost to Work Order inputs.xml
(37.63 KiB) Downloaded 45 times
Mike Sheen
Chief Software Engineer
Jiwa Financials

If I do answer your question to your satisfaction, please mark it as the post solving the topic so others with the same issue can readily identify the solution
User avatar
Mike.Sheen
Overflow Error
Overflow Error
 
Posts: 2444
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 756

Re: Adding column to Work Order Inputs grid

Postby DannyC » Mon Jul 06, 2020 7:12 pm

That's awesome Mike. I never would've nutted that one out.
One issue, although the cell is JiwaCurrencyCellType() and the decimals is set to 2, it is still displaying as a whole integer.

How can I get it to display with at least 2 decimals?

Also, I see you're using item.Inventory.LCost.
Can you use the Line Details last cost?
It looks like it'd be item.LineDetails.Value.
User avatar
DannyC
Senpai
Senpai
 
Posts: 636
Joined: Fri Mar 22, 2013 12:23 pm
Topics Solved: 30

Re: Adding column to Work Order Inputs grid

Postby Mike.Sheen » Mon Jul 06, 2020 9:47 pm

DannyC wrote:One issue, although the cell is JiwaCurrencyCellType() and the decimals is set to 2, it is still displaying as a whole integer.

How can I get it to display with at least 2 decimals?


The most explicit way is when you set the value, use the GridDecimalPlaces method of the grid to set the decimals - this overrides all other factors for determining decimals, such as the decimal places property of the cell type and the column.

DannyC wrote:Also, I see you're using item.Inventory.LCost.
Can you use the Line Details last cost?
It looks like it'd be item.LineDetails.Value.


Yeah I had to guess what you intended it to be - Line total was ambiguous to me, so I just used a simple example. Even now I can't say for sure what you want the value to represent.
Mike Sheen
Chief Software Engineer
Jiwa Financials

If I do answer your question to your satisfaction, please mark it as the post solving the topic so others with the same issue can readily identify the solution
User avatar
Mike.Sheen
Overflow Error
Overflow Error
 
Posts: 2444
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 756

Re: Adding column to Work Order Inputs grid

Postby DannyC » Mon Jul 06, 2020 11:26 pm

use the GridDecimalPlaces method
.
Sweet. That's sorted that one.

I thought I could write a foreach loop to get each LineDetail but I'm having trouble working out the type of LineDetails. It seems to be JiwaFinancials.Jiwa.JiwaApplication.Inventory.SOH.LineDetail with a <T> but I can't work out the correct C# syntax. The compiler doesn't like
Code: Select all
foreach(JiwaFinancials.Jiwa.JiwaApplication.Inventory.SOH.LineDetail itemDetail in item.LineDetails)


EDIT: Never mind...I sussed it out with some trial and error.
This is the final bit of code which displays the line total to 4 decimals.
Code: Select all
         if (row != -1)
         {
            decimal mylinetotal = 0;
            //workOrderForm.InputsJiwaGrid.set_GridText("TotalCost", row, item.Inventory.LCost * item.Quantity);
            workOrderForm.InputsJiwaGrid.GridDecimalPlaces("TotalCost", row, 4);
            foreach(JiwaFinancials.Jiwa.JiwaApplication.Inventory.SOH.LineDetail<JiwaFinancials.Jiwa.JiwaBillOfMaterials.WorkOrder.InputItem> itemDetail in item.LineDetails)
            {
               mylinetotal = mylinetotal + (itemDetail.Quantity * itemDetail.OriginalCost);
            }
            workOrderForm.InputsJiwaGrid.set_GridText("TotalCost", row, mylinetotal);
            
         }
User avatar
DannyC
Senpai
Senpai
 
Posts: 636
Joined: Fri Mar 22, 2013 12:23 pm
Topics Solved: 30

Re: Adding column to Work Order Inputs grid

Postby SBarnes » Tue Jul 07, 2020 6:39 am

If you want to set the decimal places for a column I usually just do this

Code: Select all
jgLines.AddColumn("Price", new JiwaFinancials.Jiwa.JiwaApplication.JiwaManageGrid.JiwaCurrencyCellType() {DecimalPlaces = 2}, "Price", 10, false, true, false,false);
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1617
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 175

Re: Adding column to Work Order Inputs grid

Postby DannyC » Tue Jul 07, 2020 7:50 pm

There's a problem with this plugin which I've taken a stab at fixing but the solution eludes me.
When a Work Order is already at a status of started and the status is edited to Forecast, the totals disappear. That's explainable because the plugin gets the sum of SOH taken.
But when the previous W/O is selected the column stays blank. In fact, it's only when you close work orders and go back in do the totals return. If an edit is done, the totals disappear & they don't come back no matter what the status of the W/O.

I've debugged the code and have found there are 2 issues.
The line
Code: Select all
string stageRecID = workOrderForm.StagesJiwaGrid.get_GridText("RecID", workOrderForm.StagesJiwaGrid.ActiveSheet.ActiveRowIndex).ToString();

is not returning a value to stageRecID.
Likewise, the following code isn't finding a value for workOrderForm.InputsJiwaGrid.get_GridText("RecID", inputRow).ToString()
Code: Select all
if (workOrderForm.InputsJiwaGrid.get_GridText("RecID", inputRow).ToString() == item.RecID)

It's like the get_GridText only works if you open a new W/O form.
User avatar
DannyC
Senpai
Senpai
 
Posts: 636
Joined: Fri Mar 22, 2013 12:23 pm
Topics Solved: 30

Re: Adding column to Work Order Inputs grid

Postby DannyC » Wed Jul 08, 2020 6:58 pm

This is seriously doing my head in. Ive been trying to debug this for a few hours and am still no closer.
Not only does there seems to be something odd with get_GridText but I've also discovered that the condition
Code: Select all
for (int inputRow = 0; inputRow < workOrderForm.InputsJiwaGrid.ActiveSheet.RowCount; inputRow++)
is not being met so the code within that for loop never fires. It only happens when scrolling through other work orders after a work order has been edited, e.g. the status changed.

Maybe it's some peculiar behaviour with the Infragistics grid control? Be keen to find a solution.
User avatar
DannyC
Senpai
Senpai
 
Posts: 636
Joined: Fri Mar 22, 2013 12:23 pm
Topics Solved: 30

Re: Adding column to Work Order Inputs grid

Postby SBarnes » Wed Jul 08, 2020 7:18 pm

It looks like it might be sequence of events Mike and Scott are fairly consistent so if it works like other forms the rows are being removed and they are incrementing the row count as each line gets drawn would be my guess, without seeing the plugin I can't comment further but this might help

https://help.infragistics.com/Help/Doc/ ... rt_EV.html
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1617
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 175

Re: Adding column to Work Order Inputs grid

Postby DannyC » Wed Jul 08, 2020 11:05 pm

without seeing the plugin I can't comment further

The plugin is in the fist reply post from Mike. Scroll up.

It's definitely something with
Code: Select all
workOrderForm.InputsJiwaGrid.ActiveSheet.RowCount
.
Whenever a work order is edited and saved, the RowCount is 0. Even when scrolling to another work order.
Last edited by DannyC on Wed Jul 08, 2020 11:44 pm, edited 1 time in total.
User avatar
DannyC
Senpai
Senpai
 
Posts: 636
Joined: Fri Mar 22, 2013 12:23 pm
Topics Solved: 30

Next

Return to Technical and or Programming

Who is online

Users browsing this forum: No registered users and 1 guest