on 03-11-2015 3:06 AM
Dear Expert,
I want insert new tab to system form then create grid to update custom table .
I can create a tab but don't know how to load data from DB to grid. Can you help me?
Hi AdminX,
You cannot bind a DBDataSource to a grid directly.
You have two option,
1. Bind a DataTable to the grid and do the DataTable.ExecuteQuery("SELECT * FROM [YourTable]")
2. Use a Matrix instead of Grid, and bind the matrix column to the DBDataSource.
Regards
Edy
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi AdminX,
Just to elaborate what Edy Simon has explained, here is the sample to do it:
string Sql = "Select SelectRow as 'Select', ItemCode as 'Item Code', ItemName as 'Item Name', Qty as 'Qty.', DocRef , LineID , ProjectDescription as 'Project Details', Project From [@TEMPTABLEFORMATERIALREQUEST] Where UserLogin = '" + SBO_Company.UserName + "'";
this.oForm.DataSources.DataTables.Add("MYDATATABLE");
this.oForm.DataSources.DataTables.Item(0).Clear();
this.oForm.DataSources.DataTables.Item(0).ExecuteQuery(Sql);
SAPbouiCOM.Grid oGrid = (Grid)this.m_SBO_Form.Items.Item("GridID").Specific;
oGrid.DataTable = this.oForm.DataSources.DataTables.Item("MYDATATABLE");
SAPbouiCOM.EditTextColumn oEditColumn;
oEditColumn = ((SAPbouiCOM.EditTextColumn)(oGrid.Columns.Item("DocRef")));
oEditColumn.Visible = false;
oEditColumn = ((SAPbouiCOM.EditTextColumn)(oGrid.Columns.Item("LineID")));
oEditColumn.Visible = false;
oEditColumn = ((SAPbouiCOM.EditTextColumn)(oGrid.Columns.Item("Select")));
oEditColumn.Type = BoGridColumnType.gct_CheckBox;
oEditColumn = ((SAPbouiCOM.EditTextColumn)(oGrid.Columns.Item("Item Code")));
oEditColumn.Editable = false;
oEditColumn = ((SAPbouiCOM.EditTextColumn)(oGrid.Columns.Item("Item Name")));
oEditColumn.Editable = false;
oGrid.AutoResizeColumns();
oEditColumn = ((SAPbouiCOM.EditTextColumn)(oGrid.Columns.Item("Item Code")));
oEditColumn.LinkedObjectType = "4";
Hope it helps.
Thanks & Regards
Ankit Chauhan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi AdminX,
If you want to update the form after the user press Ctr+s, you need to catch the event after key down, and check for the pVal.Modifier and pVal.CharPressed. If the modifier is 'Ctrl' key and CharPressed = "s", then go ahead with the saving.
To save, you need to write your own code to update the physical table. SBO does not help you update in this case.
If your table is UDT, use the SAPbobsCOM.UserTable object.
if your table is part of a UDO, use the GeneralService to update the record,
Suggestion, I would usually update the data on the After/Befor Form Data Update event.
This is triggered when SBO update the current form.
Regards
Edy
User | Count |
---|---|
100 | |
11 | |
10 | |
6 | |
6 | |
5 | |
4 | |
4 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.