cancel
Showing results for 
Search instead for 
Did you mean: 

How to properly select/clear all rows in a grid

ronnie_scott
Participant
0 Kudos

Hi,

I have a custom screen that shows items and their prices. The first column is a checkbox. I have a "Select All" button and a "Clear All" button. The following code does the select all function:

objForm.Freeze(True)

For i = 0 To objGrid.DataTable.Rows.Count - 1

If objGrid.DataTable.GetValue(3, i) = 0 Then

objCheck.Check(i, False)

Else

objCheck.Check(i, True)

End If

Next

objForm.Freeze(False)

objForm.Update()

I have about 1000 items loaded in the grid. It takes over a minute to select all and clear all. I have to add code for progres bar just to show that it's not hung. Yet in standard B1 UI, there are screens that you can clear all rows (like the Hierarchy screen, clear button) almost instantly. Am I doing something wrong? Is there a more efficient way to select/unselect all rows?

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

The best form that you select or clear all you rows is using the Datasources or UserDatasource, for example:

Mo_Forma.DataSources.UserDataSources.Item("itemid").Value = ValOff or ValOn

it depends of your want select or unselect.

Regards,

ronnie_scott
Participant
0 Kudos

Francisco,

I don't have a data source bound for the grid. It's only bound with data table. Are you saying I need to bind a data source for the checkbox column? How do I do that?

rasmuswulff_jensen
Active Contributor
0 Kudos

You should loop the datatable and set the datatables values instead of the UI-values... They are much faster


DataTable dt = oForm.DataSources.Datatables.Item("uid");
for(int i=0; i<dt.Rows.Count; i++)
{
  dt.SetValue("colUid",i,"New-value");
}

If you do this it will automatic be reflected in the GUI

ronnie_scott
Participant
0 Kudos

Rasmus,

This does exactly what I want. It's almost instantaneous now to have all the rows checked/unchecked. Thank you.

Ronnie

Former Member
0 Kudos

C

  1. Checkbox Check true false

for ( int i = 0; i < oGrid.Rows.Count; i++ )

{

( ( SAPbouiCOM.CheckBoxColumn ) oGrid.Columns.Item(0) ).Check(i,true);

}

Thank you,

Rune

Answers (2)

Answers (2)

Former Member
0 Kudos

When you built your form for your grid you need specify the type of your column in this case depend of your version of SAP B1, for example from B1 2004 or early you need to use

SAPbouiCOM.BoFormItemTypes.it_EDIT

and from B1 2005 to later

SAPbouiCOM.BoGridColumnType.gct_EditText

. And in your datasource as the object checkbox use two properties called ValOn or ValOff and how they receives a string, the type for your datasource for this columns would be

SAPbouiCOM.BoDataType.dt_SHORT_TEXT

, for example

Mo_Forma.DataSources.UserDataSources.Item(chkEliminaCURP).Value = "Y"

in this case value "Y" is for checked option.

I hope that this help you!

Former Member
0 Kudos

Well, If you have installed the SDK of SAP B1, you can check the folder Samples, path is some like this D:\Program Files\SAP\SAP Business One SDK\Samples\COM UI\VB.NET\06.MatrixAndDataSources\2003, this example can help you.

ronnie_scott
Participant
0 Kudos

If I add a data source, what do I use for data type for a check box column? I don't see any type that is a boolean value.