Question

I am making an add-on for SAP B1 8.82. I would like automatic row numbering for my matrix column "#" i.e. UID "V_-1". Is there a feature in 8.82 that can help me do this?

I am using UserDataSource for my matrix. How do I get to have row numbers that automatically update when I add/remove a row?

I have the following added to menu event 1292 for adding row numbers manually but cant get it to work for row deletion - menu event 1293. (Using C#)

case "1292"://Add Matrix Row
                    _form.Freeze(true);
                    _form.DataSources.UserDataSources.Item("itemNo").Value = "";
                    _form.DataSources.UserDataSources.Item("itemDesc").Value = "";
                    _form.DataSources.UserDataSources.Item("quantity").Value = "";
                    _form.DataSources.UserDataSources.Item("warehouse").Value = "";
                    _form.DataSources.UserDataSources.Item("distrRule").Value = "";
                    _form.DataSources.UserDataSources.Item("project").Value = "";
                    oMatrixItem.AddRow();

                    // row numbering   
                    int i = 1;
                    int j = 0;
                    j = oMatrixItem.RowCount;

                    while (j >= i)
                    {
                        oMatrixItem.Columns.Item("V_-1").Cells.Item(i).Specific.Value = i.ToString();
                        i = i + 1;
                    }

                    _form.Freeze(false);
                    break;
Était-ce utile?

La solution

In order to get the number in "V_-1" column simply

  1. we can bind our matrix to a table and link the line ID column to "V_-1" column
  2. we can use a DBDataSource for binding the matrix to the table and link the "V_-1" to matrix column

However if we need to maintain the serial number even after deleting the row we need to write separate code after loading the data into matrix in form load after action event.

Sample pseudo-code:

for i as integer = 1 to matrix.rowcount
    matrix.columns.itm(V_-1).item().cells(i)=i
next
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top