How to have a custom stock list with the same right click functions as standard list?

SOLVED

Hi all,

I wanted to add a bespoke columns from completely different tables to this Stock list. I think the fastest way to do it is to have a custom stock list. However, my customer also need the same right click function that able to have options as in the red box below. Is there any specific class/functions to call to get this right click options available on custom Stock list?

Thank you.

Parents
  • +1
    verified answer

    Just write a new desktop that inherits from Sage.Desktop.Lists.StockControlDesktopListForm.

    The stock list is driven by a SQL database view - STKStockItemView- so you can just amend that to join your tables in and add the required columns, then expose those columns in a new view class which inherits from Sage.MMS.View.Data.SOP.SalesOrderView, adding your additional columns in. Finally, create a new views class (deriving from ViewCollection) to act as the collection. Then override the GetSourceDataProtected() method of the desktop list to return your new view collection.

  • 0 in reply to Chris Burke

    Hi Chris, thank you that works. I change the inherits to Sage.MMS.View.Data.Stock.StockItemsView. on load, it only display Stock Code column. How do I have the other columns displayed on default?

  • 0 in reply to murni

    Oh, I've just noticed the typo in my answer. Of course I mean StockItemsView, not SalesOrderView.

    Not sure why your columns aren't showing. Override GetColumnsProtected() in your desktop list form and see what the base.GetColumnsProtected() method is returning - they should be the defaults. 

  • 0 in reply to Chris Burke

    It is returning 4 columns Code, name, Sales Price, and Actual Quantity. However, the list initially display Code column only. I had to add Name and Reserved Stock (the custom column) manually.

    This is my code to override GetColumnsProtected(). Not sure what went wrong in the code.

    protected override List<Sage.ObjectStore.Controls.ListColumn> GetColumnsProtected()
    {
        // get the original columns from the base list
        List<Sage.ObjectStore.Controls.ListColumn> list = base.GetColumnsProtected();
        Logger.WriteLog($"list.Count={list.Count};");
        foreach (Sage.ObjectStore.Controls.ListColumn l in list)
        {
            Logger.WriteLog(l.Caption);
        }
    
        // add a new column
        Sage.ObjectStore.Controls.ListColumn column = new Sage.ObjectStore.Controls.ListColumn();
        column.DisplayMember = "PendingStock";
        column.Caption = "Reserved Stock";
        column.Width = 100;
        list.Add(column);
    
        return list;
    }

  • 0 in reply to murni

    You can get some strange behaviour if the serialized memento files have got some odd things in them. Sometimes I get this problem when I'm switching between running in debug and running in 'production' on my machine. These files are stored under <user>\AppData\Roaming\IsolatedStorage\<weird directory name>.

    Search for files with a name that looks something like this:

    4_Increase.TGA.UI.Desktops.StockControlDesktopListForm_desktop.formstate

    Obviously, that's one of my custom forms, but you can see how the filename follows the namespace of the class. Close Sage 200 and delete any files you find that relate to your custom desktop, and see if it behaves when you restart Sage 200 and reload the desktop.

  • 0 in reply to Chris Burke

    After delete the file related, I am able to get the default columns and the custom column displayed. Thank you.

Reply Children
No Data