Fill Matrix / Grid problems

Erik van Dongen

I added a folder to the Business Partner Form. On this folder i want to show a matrix or a grid, connected to a table in the database (@MyTable). I want to add, edit and delete data.

My first opinion was to create a matrix. I read that this was a better solution when you want to update data in a table. I know how it works with the SAP Framework (using dbDataSource and setBind the columns) but i can't find anything like a dbDataSource in the CoreSuite Framework. My first question is how can i bind a matrix to @MyTable. Or is it possible to bind a collection of the DTO's, described in the Developer Guide?

Because i wasn't able to bind the data to a matrix, i started with a grid. It is easy to bind the data to the grid but after that, i run into several problems. I'm not able to enable the delete row button I get an error that it is not possible on system forms. How can i delete a row out of a grid?

When i fill in a row, i'm not able to fill the nextrow. Do i have to manualy add a row in the code? If so, when is the best to do? When i fill in the first column of the first row?

When i use a chooseFromList in a grid column, i'm able to select a record but I'm missing the little picturebutton to get the chooseFromList back. I have do clear the textbox and click on tabl again. In the SystemForms, there is always a little round picture where you can click on to open the chooseFromList again.

I don't know if the problems listed above are gone when i use a matrix instead of a grid but i would like to hear your opion on how to solve this issues.

Thanks,
Erik

Marco Schweighauser

You can still access the original Matrix object by using the SDK Application object.

The framework does not support all of the matrix functions it is possible that bind to system datasource is one of them.

The Grid on the other side does not support all the functionalities the Matrix provides as you already noticed. But its in general the better joice since the loading is way faster.



Kind regards,

Marco

unknown

Hoi Eric,
It is possible to do delete/change records, but you will need to:
- enable some menus (eg:1293) and
- catch a lot of grid and menu events.

Which you will be able to catch by using:
- new_menu (eg: OK/UPDATE button on your own form) and
- optimizer (a must for KeyDown/ValueChanged on the grid!) but for others like
- pressing context menu itself requires to use extended_code with fancy SDK menu event handling.

If you do that, do not forget that SDK objects need explicit destructors as they are not managed. (The menu events are global and will catch ANY event so you will need to use Form.UniqueID to filter the proper form. Besides, each time you open the form, you will load another event handler, so make sure you remove them when you close the form.

That part of code will look like:


//

//~~~~~~~~~~~~~~~~~~~~~
// get SBO Application
private SAPbouiCOM.Application o_Application;
o_Application = SwissAddonFramework.B1Connector.GetB1Connector().Application;


/*constructor part:*/

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// add event handled by SBO_Application_MenuEvent
o_Application.MenuEvent += new SAPbouiCOM._IApplicationEvents_MenuEventEventHandler( Application_MenuEvent );




/*destructor part:*/

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// add event handled by SBO_Application_MenuEvent

o_Application.MenuEvent -= new SAPbouiCOM._IApplicationEvents_MenuEventEventHandler( Application_MenuEvent );




Then all the record numbers you are changing you will have to put into userdatasource1 (use the one from SDK not CS) and those you delete into userdatasource2. Before pressing UPDATE you will simply lookup those datasources and handle accordingly.

To check grid for row selection use something like that:

//
/*actual Delete_Row context menu event part*/
SwissAddonFramework.UI.Components.Form o_f1 = SwissAddonFramework.UI.Components.Form.GetFormFromUID(v_FormUniqueID);
SwissAddonFramework.UI.Components.Grid o_f1_g1 = SwissAddonFramework.UI.Components.Grid.GetFromUID(o_f1, "grd_0001");
if (o_f1_g1.SelectedRows.Count > 0)
{
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// selection mode is set to single so there may be only one selected row.
int v_Row = o_f1_g1.SelectedRows.RowIndex(0 , SwissAddonFramework.UI.Components.Grid.SelectedGridRows.OrderTypes.SelectionOrder);
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// gets unigue Key for the UDO
string v_Code = o_f1_g1.GetValue("Code" , v_Row);
}


Adding a record will be quite analogous...
0

Comments

0 comments

Please sign in to leave a comment.

Didn't find what you were looking for?

New post