04-27-2017 10:58 AM - edited 02-03-2024 8:23 PM
Hi All,
I am Using UDT as DB Data source.I created a User Form With Matrix,Add Row Button and Delete Row Button.
1.Add Row Button is Working Correctly
2.When I Clicked Delete Row Button,......... Row in Matrix is Deleted But Not Deleted in Data Source...odbDataSource.RemoveRecord(0) this line is not working
Please Help Me to Solve this Issue
Hi Chidambaram,
You can perform this action with this:
Add row:
oMtx.AddRow(1, your index);
oMtx.FlushToDataSource();
Delete Row:
oMtx.DeleteRow(your index);
oMtx.FlushToDataSource();
Every time when you call FlushToDataSource method, the SDK will update the datasource with the values of your matrix.
Hope it helps.
Kind Regards,
Diego Lother
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi DIEGO LOTHER
Thanks For Your Reply.
Still I am Facing the Same Problem.Matrix Row Only Deleted But the same record in Data Source is Not Deleted.
Kind Regards,
Chidambaram
Hi DIEGO LOTHER
Here is the Code
Matrix Bind Code
Public Sub BindDataToForm()
oColumns = oMatrix.Columns
oColumn = oColumns.Item("Final1")
oColumn.DataBind.SetBound(True, "@UDT", "UDF")
oColumn = oColumns.Item("Check")
oMatrix.Columns.Item("Check").ValOff = "N"
oMatrix.Columns.Item("Check").ValOn = "Y"
oMatrix.Columns.Item("Check").DataBind.SetBound(True, "@UDT", "UDF")
oItem = oForm.Items.Add("AddRow", SAPbouiCOM.BoFormItemTypes.it_BUTTON)
oItem.Left = 360
oItem.Top = 160
obutton = oItem.Specific
obutton.Caption = "Add Row"
oItem = oForm.Items.Add("DeleteRow", SAPbouiCOM.BoFormItemTypes.it_BUTTON)
oItem.Left = 220
oItem.Top = 160
obutton = oItem.Specific
obutton.Caption = "DeleteRow"
'// DELETE ROW
Private Sub SBO_Application_ItemEvent(ByVal FormUID As String, ByRef pVal As SAPbouiCOM.ItemEvent, ByRef BubbleEvent As Boolean) Handles SBO_Application.ItemEvent
Dim ds As SAPbouiCOM.DBDataSource
If ((pVal.FormUID = "fORMuid") And (pVal.ItemUID = "AddRow") And (pVal.EventType = SAPbouiCOM.BoEventTypes.et_ITEM_PRESSED) And (pVal.BeforeAction = True)) Then
ds = oForm.DataSources.DBDataSources.Item("@UDT")
ds.Clear()
Dim count As Integer = oMatrix.RowCount
oMatrix.AddRow(1, count)
oMatrix.Columns.Item(1).Cells.Item(oMatrix.RowCount).Click(SAPbouiCOM.BoCellClickType.ct_Regular)
End If
If ((pVal.FormUID = "fORMuid") And (pVal.ItemUID = "DeleteRow") And (pVal.EventType = SAPbouiCOM.BoEventTypes.et_ITEM_PRESSED) And (pVal.BeforeAction = False)) Then
Dim irow As Integer
Dim oExeMatDtl As SAPbouiCOM.DBDataSource
irow = oMatrix.GetNextSelectedRow(0, SAPbouiCOM.BoOrderType.ot_SelectionOrder)
oExeMatDtl = oForm.DataSources.DBDataSources.Item("@UDT")
oExeMatDtl.Clear()
Try
oMatrix = oForm.Items.Item("Matrix1").Specific
oMatrix.DeleteRow(irow)
oMatrix.IsRowSelected(irow)
oForm.DataSources.DBDataSources.Item("@UDT").RemoveRecord(irow)
oMatrix.FlushToDataSource()
Catch ex As Exception
MsgBox(ex.Message)
End Try
If oForm.Mode = SAPbouiCOM.BoFormMode.fm_ADD_MODE Then
oForm.Mode = SAPbouiCOM.BoFormMode.fm_UPDATE_MODE
End If
End If
Hi Chidambaran,
Try with this changes:
For Add Row:
If ((pVal.FormUID = "fORMuid") And (pVal.ItemUID = "AddRow") And (pVal.EventType = SAPbouiCOM.BoEventTypes.et_ITEM_PRESSED) And (pVal.BeforeAction = True)) Then
Dim count As Integer = oMatrix.RowCount
oMatrix.AddRow(1, count)
oMatrix.FlushToDataSource()
oMatrix.Columns.Item(1).Cells.Item(oMatrix.RowCount).Click(SAPbouiCOM.BoCellClickType.ct_Regular)
End If
For Delete Row:
If ((pVal.FormUID = "fORMuid") And (pVal.ItemUID = "DeleteRow") And (pVal.EventType = SAPbouiCOM.BoEventTypes.et_ITEM_PRESSED) And (pVal.BeforeAction = False)) Then
Dim irow As Integer
irow = oMatrix.GetNextSelectedRow(0, SAPbouiCOM.BoOrderType.ot_SelectionOrder)
Try
oMatrix = oForm.Items.Item("Matrix1").Specific
oMatrix.DeleteRow(irow)
oMatrix.FlushToDataSource()
Catch ex As Exception
MsgBox(ex.Message)
End Try
If oForm.Mode = SAPbouiCOM.BoFormMode.fm_ADD_MODE Then
oForm.Mode = SAPbouiCOM.BoFormMode.fm_UPDATE_MODE
End If
End If
Only remember that delete row from a dbdatasource does not reflect directly on database, only on the object on the form.
If you want delete or add a row for database you need use DI API together with UI API.
Hope it helps.
Kind Regards,
Diego Lother
User | Count |
---|---|
101 | |
12 | |
11 | |
6 | |
6 | |
4 | |
3 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.