cancel
Showing results for 
Search instead for 
Did you mean: 

Load Matrix and ready for Editing

Former Member
0 Kudos

Hi,

How do I load a matrix and bind to a datasource and have multiples rows ready for editing?

I would usually bind the datasource follow by the columns but that doesn't make the rows editable.

Set oMatrix = oForm.Items.Item("1").Specific

Set oColumns = oMatrix.Columns

Set oDBDataSource = oForm.DataSources.DBDataSources.Add("@TableName")

Set oColumn = oColumns.Item("No")

oColumn.DataBind.SetBound True, "@TableName", "U_ItemNo"

.

.

oMatrix.Clear

Please note, I am using VB6. Help appreciated. Thanks.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Alexey,

How can I select the first cell in the newly added row?

Former Member
0 Kudos

oMatrix.Columns.Item("FirstColumnUID").Cells.Item(oMatrix.RowCount).Click

AlexGrebennikov
Active Contributor
0 Kudos

you can click in it by code:

Matrix.Columns.Item("1stColumn").Cells.Item(Matrix.RowCount).Click(SAPbouiCOM.BoCellClickType.ct_Regular)

<i>Message was edited by: Alexey Grebennikov

Adele was faster :)</i>

Answers (3)

Answers (3)

Former Member
0 Kudos

Yes, you are right that we do not know how many rows the user will add.

Is there a way to use 'Enter' or 'Shift-Enter' or click on the cell in next row, to automatically add row beside using et_Validate?

We loop through the matrix using oDBDataSource.Size to save the data. An exception was thrown when an attempt was made to save an empty row. Any suggestion to overcome this?

Thanks.

AlexGrebennikov
Active Contributor
0 Kudos

Yes, certanly, you can simply add one more row when user presses Enter (or Sh-Enter).

Just add the next condition into your ItemEvent-handler:

if (pVal.EventType == SAPbouiCOM.BoEventTypes.et_KEY_DOWN)
	if 
	(
		pVal.ColUID == "Col1" && 
		pVal.Action_Success == false &&
		pVal.CharPressed == 13 &&
		pVal.Modifiers == SAPbouiCOM.BoModifiersEnum.mt_SHIFT // or mt_None
	)
		tblItems.AddRow(-1, 0)

Former Member
0 Kudos

Alexey,

oMatrix.AddRow() will probably prepare a single row for editing. But end user will have to edit on multiple rows, how do I overcome this situation. Please take note that I will have to save the matrix after editing. I hope preparing multiple rows will not raise exception when I save.

Thanks for responding.

AlexGrebennikov
Active Contributor
0 Kudos

I suppose you don't know at the time how many rows the end-user needs to add?!

If so you should deside which column is main,catch et_Validate event on it and add one more row by AddRow()-method. In this case you'll get the same implementation of rows auto-adding as in SAPDocs.

Former Member
0 Kudos

I would be glad if someone can help me out in this. Do let me know if you need further info. Thanks again.

AlexGrebennikov
Active Contributor
0 Kudos

Hi!

After Matrix.Clear() you have not any rows in matrix, that's why you are thinking that matrix in noneditable.

<b>Matrix.AddRow()</b> should help you.