Skip to Content

SetLineData(i) changing values of al matrix rows

HI all,

Im trying to set the value of a particular rows userdatasource bound matrix column value. But it seems like all the rows value gets changed. Please assist.

private void OnCustomInitialize()
{ //GET THE USER DATA SOURCE
Uds = this.UIAPIRawForm.DataSources.UserDataSources;
//ADD new datasource Uds.Add("MX_DESC", SAPbouiCOM.BoDataType.dt_SHORT_TEXT, 100);
//BIND Matrix COLUMN this.mtxContents.Columns.Item("colItmName").DataBind.SetBound(true, "", "MX_DESC");
this.mtxContents.Columns.Item("colItmName").ChooseFromListUID = "cflOITM2";
this.mtxContents.Columns.Item("colItmName").ChooseFromListAlias = "ItemName";
} //SET VALUE IN THE EVENT private void MtxContents_ChooseFromListAfter(object sboObject, SBOItemEventArg pVal) { Matrix mat = null; if (pVal.ActionSuccess) { SBOChooseFromListEventArg oCFLEvento = (SBOChooseFromListEventArg)pVal; var dataTable = oCFLEvento.SelectedObjects; var itemName = dataTable.GetValue("ItemName", 0).ToString(); mat = this.mtxContents; mat.GetLineData(pVal.Row); Uds.Item("MX_DESC").ValueEx = itemName; mat.SetLineData(pVal.Row); } }
Add a comment
10|10000 characters needed characters exceeded

Related questions

2 Answers

  • Best Answer
    Posted on Jul 21, 2020 at 01:48 AM
    Uds.Item("ItemName").ValueEx = ""; // userdatasource
    Dbds_ACQ1.Clear();// db datasource 
    this.mtxContents.AddRow(1);//add row 
    this.mtxContents.FlushToDataSource();//flush current matrix data back to datasource
    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jul 08, 2020 at 06:09 AM

    When you add new row at matrix, you should clear data of row.

    private void Button0_ClickBefore(object sboObject, SAPbouiCOM.SBOItemEventArg pVal, out bool BubbleEvent)
    {
        BubbleEvent = true;
        Matrix0.AddRow();
        //Clear new row data
        Matrix0.ClearRowData(Matrix0.RowCount);
    }
    private void Matrix0_ChooseFromListAfter(object sboObject, SAPbouiCOM.SBOItemEventArg pVal)
    {
        try
        {
            if (pVal.ActionSuccess)
            {
                SAPbouiCOM.SBOChooseFromListEventArg cfl = ((SAPbouiCOM.SBOChooseFromListEventArg)(pVal));
                if (cfl.SelectedObjects == null)
                {
                    return;
                }
                else
                {
                    Matrix0.GetLineData(pVal.Row);
                    this.UIAPIRawForm.DataSources.UserDataSources.Item("UD_0").Value = cfl.SelectedObjects.GetValue("ItemCode", 0).ToString();
                    this.UIAPIRawForm.DataSources.UserDataSources.Item("UD_1").Value = cfl.SelectedObjects.GetValue("ItemName", 0).ToString();
                    Matrix0.SetLineData(pVal.Row);
                }
            }
        }
        catch (Exception e)
        {
            Application.SBO_Application.SetStatusBarMessage(e.Message,SAPbouiCOM.BoMessageTime.bmt_Short);
        }
    }
    Add a comment
    10|10000 characters needed characters exceeded

    • Thanks.
      We have DB datasource, so only adding row to matrix and clearing it doesnt work.
      The following looks ok

                      Uds.Item("ItemName").ValueEx = ""; // userdatasource 
      Dbds_ACQ1.Clear(); // db datasource
      this.mtxContents.AddRow(1); // add row
      this.mtxContents.FlushToDataSource(); // flush current matrix data back to datasource

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.