cancel
Showing results for 
Search instead for 
Did you mean: 

Setting EditText value problem.

Former Member
0 Kudos

Hi

I try to set some values on matrix object using EditText string property.

I have this simple code


 ...
 Cell cell1 = matrix.Columns.Item("col_5").Cells.Item(pVal.Row);
 EditText editText1 = (EditText)cell1.Specific; 
 editText1.String = sTotal;
 
 Cell cell2 = matrix.Columns.Item("col_6").Cells.Item(pVal.Row);
 EditText editText2 = (EditText)cell2.Specific;
 editText2.String = sTotal1;
 ...

but when it reaches editText1.String = sTotal line it goes back to Cell cell1...

It goes then on and on unitl SAP crashes.

What is the problem?

Thanks in advance

Kamil

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Dear Kamil,

By SAP Note 700670, To prevent performance problems, we recommend that you use the

data sources to fill matrix object cells instead of filling the matrix cell by cell.

Here the sample code in the Note 700670:


'Define different user data sources
Set us_col1 = frm.DataSources.UserDataSources.Add
"us_col1", SAPbouiCOM.dt_SHORT_TEXT, 10
Set us_col2 = frm.DataSources.UserDataSources.Add
"us_col2", SAPbouiCOM.dt_SHORT_TEXT, 10
Set us_col3 = frm.DataSources.UserDataSources.Add
"us_col3", SAPbouiCOM.dt_SHORT_TEXT, 10
Set us_col4 = frm.DataSources.UserDataSources.Add
"us_col4", SAPbouiCOM.dt_SHORT_TEXT, 10
Set us_col5 = frm.DataSources.UserDataSources.Add
"us_col5", SAPbouiCOM.dt_SHORT_TEXT, 10
'associate columns with data sources
Set col1 = mtx.Columns.Add
("col1", SAPbouiCOM.it_EDIT)
col1.DataBind.SetBound True, "", "us_col1"
Set col2 = mtx.Columns.Add
("col2", SAPbouiCOM.it_EDIT)
col2.DataBind.SetBound True, "", "us_col2"
Set col3 = mtx.Columns.Add
("col3", SAPbouiCOM.it_EDIT)
col3.DataBind.SetBound True, "", "us_col3"
Set col4 = mtx.Columns.Add
("col4", SAPbouiCOM.it_EDIT)
col4.DataBind.SetBound True, "", "us_col4"
Set col5 = mtx.Columns.Add
("col5", SAPbouiCOM.it_EDIT)
col5.DataBind.SetBound True, "", "us_col5"

 'Fills matrix
 For ii = 0 To 19
 For jj = 0 to colNum
 frm.DataSources.UserDataSources(jj).Value = "stam" & ii
 && jj
 Next jj
 'After setting all the relevant data sources and the line to matrix
 mtx.AddRow
 Next ii

Best Regards

Jane Jing

SAP Business One Forums team

Former Member
0 Kudos

Thanks Jane

This is in some sense funny because I wanted to avoid using data source method because it produces

this nasty scroll behaviour that is unacceptable.

I tried different solutions to this problem without any good solution and that is why I turned into filling my column

cell by cell.

When I have a matrix that have 300 columns and I want to change something at, for instance, column 234 I have to recompute

and show the results.

I used load from data source method but it rewinds back to the beginning of the matrix.

This behaviour is unacceptable for my client.

As I said I tried different solutions but none of them work the way it should.

I will try to use user data sources and see if it will solve my problem.

Thanks

Kamil

Answers (4)

Answers (4)

budin
Discoverer
0 Kudos

Funny, I found the problem cause of FMS that Return More Than 1 Value.

So work around is

oForm.DataSources.DBDataSources.Item(Object Name).SetValue(Field Name, Record Number - 1, New Value)

oMatrix.LoadFromDataSource()

Former Member
0 Kudos

Dear Kamil,

By SDK help the Column Type list in BoFormItemTypes Enumeration:

Member Description

it_BUTTON Button. Not relevant for column type.

it_STATIC Static text. Not relevant for column type.

it_EDIT Text Box.

it_FOLDER Pipe. Not relevant for column type.

it_RECTANGLE Frame rectangle. Not relevant for column type.

it_COMBO_BOX Combo Box (List Box, Popup, etc.)

it_LINKED_BUTTON Link arrow to other items.

it_PICTURE Image.

it_EXTEDIT Text Box with multiple lines.

it_CHECK_BOX Check Box.

it_OPTION_BUTTON Option Button. Not relevant for column type.

it_MATRIX Matrix (table). Not relevant for column type.

it_GRID Table.

it_PANE_COMBO_BOX Pane Combo Box. Not relevant for column type.

it_ACTIVE_X ActiveX object.

Please make sure use the it_EDIT type for your column.

Best Regards

Jane Jing

SAP Business One Forums team

Former Member
0 Kudos

Hello Jane

I checked and it is it_EDIT type.

Still I can't change it's value with edit text string property.

Thanks

Kamil

Former Member
0 Kudos

Hi,

Use a try catch block and check for the exact error. And as u said that the loop is not stopping may be some thing is wrong with ur loop, post that code too..

Vasu Natari.

Former Member
0 Kudos

Sorry If I wasn't clear enough.

The part of code I have trouble with is outside of loop in a sense of language construct.

When I go into the debugger it goes like this

line1

then

line 2

then

line3

Oops, some problem it goes back to line 1.

It goes on and on until it crashes.

I don't use any loop myself.

Here is the part that "loops"


Cell cell2 = matrix.Columns.Item("col_6").Cells.Item(pVal.Row);
EditText editText2 = (EditText)cell2.Specific;
editText2.String = sTotal;

Former Member
0 Kudos

Hi Kamil,

Had you seen my earlier post in the same thread, perhaps that code piece might solve your problem in this problem. That one line of mine will suffice all three lines you have written. Moreover, try getting the value in the field using a msg box before and after that given line.

Regards,

Satish. B.

Former Member
0 Kudos

Sorry Satish but when I use (as You suggested)


((SAPbouiCOM.EditText)matrix.Columns.Item("col_5").Cells.Item(pVal.Row).Specific).String = sTotal;

it is looping on the same line over and over (until it finally crashes)

I tried moving my code to different places. Still the same behaviour.

Type of my column is indeed it_EDIT so it should work.

I wonder if this is due to the fact that I'm using B1DE. After all it is additional layer of code.

Edited by: kamil_w on Sep 9, 2009 11:40 AM

Edited by: kamil_w on Sep 9, 2009 11:43 AM

Former Member
0 Kudos

Dear kamil_w,

What column type of "col_5" and what data type do you bind with the column "col_5"? Is it EditText type?

Best Regards

Jane Jing

SAP Business One Forums team

Former Member
0 Kudos

Hello Jane

My column' type is 16 whatever that means and I have this column data bounded to db data source.

I'm wondering if the fact that it's bounded counts but I want to change value of the matrix cell only.

I created my addon with B1DE. (UDO)

Thanks

Kamil

Former Member
0 Kudos

HI Kamil,

Don't use the cell object at all. Rather, use the Edit Text property directly. Check the below piece of code.

((SAPbouiCOM.EditText)oMatrix.Columns.Item(3).Cells.Item(Row).Specific).Value = strValue;

Hope this helps.

Regards,

Satish.

Former Member
0 Kudos

Thanks Satish but unfortunately it doesn't change anything.

Still I got this strange behaviour where it loops unit SAP crashes.

I wonder if this problem is because I have this column data bounded.

But I can change this column' value by hand.

Thanks anyway

Kamil