Solved

Is It Possible to bind two views to a single grid?

  • 15 September 2023
  • 10 replies
  • 116 views

Userlevel 3
Badge
  • Jr Varsity III
  • 37 replies

Hi, i have Created a form and grid in a popup of action methrod. i have added a selector to the form and when i select a value from selector, grid gets triggered and its working fine, now i want to add another selector and that selector should trigger the same grid,   any help is highly appreciated

Thanks in advance

icon

Best answer by darylbowman 15 September 2023, 21:28

View original

10 replies

Userlevel 5
Badge +3

For me it sounds, like you want to have two selectors for two different columns in the grid. If that is the case, then yes, you may have two selectors for two different columns. As an example you can look for plenty of forms of Acumatica, when one column selector has dependency from what is selected in another selector. For example Projects and project tasks forms.

Badge +11

Some additional information would be helpful. What does selecting a value with selectors do to the grid? Filter it? Fill it with data?

Userlevel 3
Badge

Firstly i have created a action with a popup in Sales order screen. And i have added a selector for inventory, and we i select a record in inventory selector then it displays all the invoice items for that paticular inventory and paticular customer in the grid of sales order screen.  now i need to add another selector besides inventory selector to filter data by Alternate id for stock items,  i want to use the same grid to work for both the selectors,  is that possible?

 

Userlevel 3
Badge

@Yuriy Zaletskyy  No, i want to all the feilds on same grid, for eaither of the two selectors

 

Userlevel 3
Badge

@darylbowman , I have Created a popup with inventory id selector. when i select it, it pulls all the invoice for that paticular inventory and customer of the current Sales order screen. now i want to append the funtionality i.e i want to add anothe selector that displays all Alternate ids for the stock item and when i select it it should funtion in the same way that is display all the invoices for that inventory

 

Badge +11

Yes, this is possible, and by your description will work exactly like the filter fields on many Acumatica screens. You simply need to include the selected values in the conditions of the data view you have bound to the grid.

If you want them to work independently (one at a time), you should write code to erase one when the other is updated.

If they can work together (both at once), then build that into your logic.

Userlevel 3
Badge

@darylbowman , So You mean to say If we change the Condtion of Grid View then we can Acheive it?, Hear is my code, can you please look at it once and guide me

 public PXAction<SOOrder> InvFilter;
        [PXUIField(DisplayName = "Invoice Filter", Enabled = true)]
        [PXButton(CommitChanges = true)]
        public virtual IEnumerable invFilter(PXAdapter adapter)
        {

            var q = Invview.Select().Count;

            var k = Invview.AskExt();
            if (this.Invview.AskExt() == WebDialogResult.OK)
            {
                foreach (ARInvoice invoice in Invview.Select())

                {
                    if (invoice.Selected == true)
                    {


                            foreach (ARTran tran1 in PXSelect<ARTran, Where<ARTran.tranType, Equal<Current<ARInvoice.docType>>, And<ARTran.refNbr, Equal<Current<ARInvoice.refNbr>>>>>.Select(Base, invoice.RefNbr, invoice.DocType))
                            {

                             
                                SOLine oLine2 = PXSelect<SOLine, Where<SOLine.orderType, Equal<Required<ARTran.sOOrderType>>, And<SOLine.orderNbr, Equal<Required<ARTran.sOOrderNbr>>, And<SOLine.lineNbr, Equal<Required<ARTran.sOOrderLineNbr>>>>>>.Select(Base, tran1.SOOrderType, tran1.SOOrderNbr, tran1.SOOrderLineNbr);
                                SOLine line1 = PXSelect<SOLine, Where<SOLine.orderType, Equal<Required<SOLine.orderType>>, And<SOLine.orderNbr, Equal<Required<SOLine.orderNbr>>, And<SOLine.lineNbr, Equal<Required<SOLine.lineNbr>>>>>>.Select(Base, tran1.SOOrderType, tran1.SOOrderNbr, tran1.SOOrderLineNbr);

                                if (line1 != null)
                                {
                                    SOLine line = new SOLine();
                                    //line.OrderType = tran1.SOOrderType;
                                    //line.OrderNbr = tran1.SOOrderNbr;
                                    line.InventoryID = line1.InventoryID;
                                    //line.UOM = tran1.UOM;
                                    line.BranchID = line1.BranchID;
                                    line.OrderQty = line1.OrderQty;
                                    line.UOM = line1.UOM;
                                    line.InvoiceNbr = invoice.RefNbr;
                                    //line.SiteID = tran1.SiteID;
                                    //line.TranDesc = tran1.TranDesc;
                                    //line.CuryUnitPrice = tran1.CuryUnitPrice;
                                    Base.Transactions.Insert(line);

                                }

                             
                            }
                        

                    }
                }
            }


            return adapter.Get();

 

 

        #region Views

        public PXSelectJoin<ARInvoice, InnerJoin<ARTran, On<ARTran.tranType, Equal<ARInvoice.docType>, And<ARTran.refNbr, Equal<ARInvoice.refNbr>>>>,
    //InnerJoin<SOOrder, On<SOOrder.orderNbr, Equal<ARTran.sOOrderNbr>>>>,
    Where<ARInvoice.customerID, Equal<Current<SOOrder.customerID>>, And<ARTran.inventoryID, Equal<Current<TestInventory.inventoryId>>>>> Invview;
 public PXSelect<TestInventory, Where<TestInventory.inventoryId, Equal<Current<TestInventory.inventoryId>>>> Testinventory;
        public PXSelect<StockAlterId, Where<StockAlterId.alternateID, Equal<Current<StockAlterId.alternateID>>>> AlternateInvId;
        public PXSelectJoin<ARInvoice, InnerJoin<ARTran,On<ARTran.tranType,Equal<ARInvoice.docType>,And<ARTran.refNbr, Equal<ARInvoice.refNbr>>>,InnerJoin<INItemXRef, On<ARTran.inventoryID, Equal<INItemXRef.inventoryID>>>>, Where<ARInvoice.customerID, Equal<Current<SOOrder.customerID>>, And<ARTran.inventoryID, Equal<Current<StockAlterId.alternateID>>>>>InvoiceView;
        #endregion

Badge +11

Something like this should get you close:

public SelectFrom<ARInvoice>.
InnerJoin<ARTran>.
On<ARTran.tranType.IsEqual<ARInvoice.docType>.
And<ARTran.refNbr.IsEqual<ARInvoice.refNbr>>>.
InnerJoin<InventoryItem>.
On<InventoryItem.inventoryID.IsEqual<ARTran.inventoryID>>.
InnerJoin<INItemXRef>.
On<INItemXRef.inventoryID.IsEqual<InventoryItem.inventoryID>>.
Where<ARInvoice.customerID.IsEqual<SOOrder.customerID.FromCurrent>.
And<InventoryItem.inventoryID.IsEqual<TestInventory.inventoryId.FromCurrent>.
Or<INItemXRef.alternateID.IsEqual<TestInventory.alterateId.FromCurrent>>>>.View Invview;

Assuming your class TestInventory has a field AlternateId.

Userlevel 3
Badge

Thank you @darylbowman ,it seems like it is Best Answer , i will check it and Respond

Userlevel 3
Badge

Thank You @darylbowman , It worked for me 

Reply


About Acumatica ERP system
Acumatica Cloud ERP provides the best business management solution for transforming your company to thrive in the new digital economy. Built on a future-proof platform with open architecture for rapid integrations, scalability, and ease of use, Acumatica delivers unparalleled value to small and midmarket organizations. Connected Business. Delivered.
© 2008 — 2024  Acumatica, Inc. All rights reserved