Matrix.AddRow "eats" rows
Hello
I'm trying to do sorting on matrix object. I'm almost there but there is small problem. Here is the code
for (int i = 0; i < dbDataSource.Size; i++)
dbDataSource.Offset = sortedList<i>.Idx;
matrix.AddRow(1, ++i);
every time I fire double click event (which contains sorting code) my matrix will show less and less items until it becomes blank.
If it helps somehow I'm posting code which I use for actual sorting.
if (pVal.ColUID == "col_dost")
matrix.Clear();
List<Dostawca> dostawcy = new List<Dostawca>();
DBDataSource dbDataSource = form.DataSources.DBDataSources.Item("@CT_PRP1");
int count = dostawcy.Count;
int k = 0;
for (int i = 0; i < dbDataSource.Size; i++)
string sValue = dbDataSource.GetValue("U_CardName", i);
Dostawca dostawca = new Dostawca();
dostawca.Nazwa = sValue;
dostawca.Idx = k;
dostawcy.Add(dostawca);
k++;
var sortedList = dostawcy.OrderBy(x => x.Nazwa).ToList();
for (int i = 0; i < dbDataSource.Size; i++)
dbDataSource.Offset = sortedList<i>.Idx;
matrix.AddRow(1, ++i);
and here is my "Dostawca" class
public class Dostawca
private string _nazwa;
private int _id;
public Dostawca() { }
public string Nazwa
get
return _nazwa;
set
_nazwa = value;
public int Idx
get
return _id;
set
_id = value;
Thanks
Kamil
Ok, never mind. I see the problem.
Similar Messages
-
Scanning a matrix with collapsible rows
Hello all,
I need to scan the right matrix (ItemUID = "2") on the "Purchase Order Confirmation" form. This matrix has collapsible rows, and I can only scan through them if they are all expanded (not collapsed).
Is there a way to check whether there are any collapsed rows in a matrix on a system form? I tried comparing Matrix.RowCount with Matrix.VisualRowCount, but it didn't work.
An even better solution cound be to expand all the matrix's rows through UIApi, but I couldn't do it either...
Thanks in advance,
AntonHi Anton,
Hope these threads will have some values to you:
Data from collapsed grid by Events
Re: difference between Matrix.Visual RowCount and ...
How do you read data from collapsed rows in a matrix
Thanks,
Gordon -
hi everybody,
I have a problem with a matrix with 838 rows, in my code i have to fill the columns of the matrix before save the sales order, i fill eight columns but when i'm filling the row 500 or sometimes the row 450 or sometimes the row 600, always is different, in the code, i fill the cell correctly just like this
oMatrix.Columns.Item("10002039").Cells.Item(row).Specific.Value = line
but when pass to the other row, i put a watch to see the value of the cell like this "oMatrix.Columns.Item("10002041").Cells.Item(row).Specific.Value" this is empty and this happens with all the following rows.
anyone know anything about this?Hi,
Is the issue is rectifed ???
if yes,can u please close the thread ....!
By marking the "Correct Answer"...
Regards,
Prasad -
Hi
I have a simple form. As soon as i click Addrow button i need to add a row in the matrix. I have opened the form first time and clicked addrow buttond a new row is getting added into the matrix. Now i have clicked the cancel button in the form. And then i reopened the form again when i click addrow button 2 new rows are getting added. but i need to add only single row.
Please let me know the solution. i have given the sample code for your reference.
Private Sub SBO_Application_ItemEvent(ByVal FormUID As String, ByRef pVal As SAPbouiCOM.ItemEvent, ByRef BubbleEvent As Boolean) Handles SBO_Application.ItemEvent
If (FormUID = "Frm_QTENT1") Then
If (pVal.Before_Action = False) Then
If (pVal.ItemUID = "Addrow") And (pVal.EventType = SAPbouiCOM.BoEventTypes.et_CLICK) Then
Dim f As SAPbouiCOM.Form
Dim oMatrix As SAPbouiCOM.Matrix
f = SBO_Application.Forms.Item(FormUID)
oMatrix = f.Items.Item("mat1").Specific
f.DataSources.DBDataSources.Item(1).Clear()
oMatrix.AddRow(1)
End If
End If
End If
End sub
You can also test . Just add a matrix to a form and then add one button. In the itemevent just past the code above and run the form. And then click addrow button
you can see a new row is added into the matrix. When cancel the form. And now open the form again now click add button only once. You can see 2 rows are getting added. The code what is pasted will be fired 2 wise .
Please let me know how can i solve this problem.
If any one able to solve this problem i will give full reward points
regards
Sureshhi,
Still i am facing the same problem. I have given the comple code. please let me have a solution for the same. When i click next sample i need to populate all the parameter for the item in the matrix. for that i have writtern the code. It works fine still i did not click cancel button. But as soon as i click cancel button and add click next sample button multiple time this item is getting fired and row are getting add for the time which i have added first time.
If (pVal.EventType = SAPbouiCOM.BoEventTypes.et_ITEM_PRESSED) And (pVal.ItemUID = "nextsample") Then
Dim oEdit As SAPbouiCOM.EditText ' Sample no
Dim oEdit1 As SAPbouiCOM.EditText ' Para code
Dim oEdit2 As SAPbouiCOM.EditText ' Para desc
Dim oEdit3 As SAPbouiCOM.EditText ' UOM Code
Dim oEdit4 As SAPbouiCOM.EditText ' UOM Name
Dim oEdit5 As SAPbouiCOM.EditText ' Standard Value
Dim oEdit6 As SAPbouiCOM.EditText ' Tollerance Pluse
Dim oEdit7 As SAPbouiCOM.EditText ' Tollerance minus
Dim i As Integer
Dim k As Integer
Dim sSQL As String
Dim oDocRec As SAPbobsCOM.Recordset
samno = samno + 1
txtsamno.Value = samno
oDocRec = Ocompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset)
sSQL = "select b.U_paracode,b.U_paradesc,b.U_UomCode,b.U_uom,b.U_value,b.U_tollplus,b.U_tollmins from [@PSSIT_QCSTANDHDR1] a, [@PSSIT_QCSTANDDTL1] b where a.U_itemcode = '" & cbogrp.Selected.Value.ToString() & "' and a.Code = b.Code"
'sSQL = "select b.U_paracode,b.U_paradesc,b.U_UomCode,b.U_uom,b.U_value,b.U_tollplus,b.U_tollmins from [@PSSIT_QCSTANDHDR1] a, [@PSSIT_QCSTANDDTL1] b where a.U_itemcode = '" & oForm.DataSource.UserDataSource.Item("ItemCode").ValueEx & "' and a.Code = b.Code"
oDocRec.DoQuery(sSQL)
Oform.Freeze(True)
'**********8
Dim f1 As SAPbouiCOM.Form
Dim oDBs As SAPbouiCOM.DBDataSource
f1 = SBO_Application.Forms.Item(FormUID)
oMatrix = f1.Items.Item("mat2").Specific
oDBs = f1.DataSources.DBDataSources.Item("@PSSIT_QCDTL1")
oDBs.Clear()
Omatrix.Clear()
' If RefFlag = False Then
Omatrix.AddRow(1)
If oDocRec.RecordCount > 0 Then
For i = 0 To oDocRec.RecordCount - 1
'MessageBox.Show(oDocRec.RecordCount)
' Omatrix.AddRow(1)
'Sample no
oEdit = matcol1.Cells.Item(totrow).Specific
oEdit.Value = CInt(samno)
matcol1.Editable = False
'Parameter code
oEdit1 = matcol2.Cells.Item(totrow).Specific
oEdit1.Value = oDocRec.Fields.Item(0).Value
matcol2.Editable = False
'Parameter Name
oEdit2 = matcol3.Cells.Item(totrow).Specific
oEdit2.Value = oDocRec.Fields.Item(1).Value
matcol3.Editable = False
'UOM Code
oEdit3 = matcol4.Cells.Item(totrow).Specific
oEdit3.Value = oDocRec.Fields.Item(2).Value
matcol4.Editable = False
'UOM Name
oEdit4 = matcol5.Cells.Item(totrow).Specific
oEdit4.Value = oDocRec.Fields.Item(3).Value
matcol5.Editable = False
'Standard Value
oEdit5 = matcol6.Cells.Item(totrow).Specific
oEdit5.Value = oDocRec.Fields.Item(4).Value
matcol6.Editable = False
'Tollerance Pluse
oEdit6 = matcol7.Cells.Item(totrow).Specific
oEdit6.Value = oDocRec.Fields.Item(5).Value
matcol7.Editable = False
'Tollerance minus
oEdit7 = matcol8.Cells.Item(totrow).Specific
oEdit7.Value = oDocRec.Fields.Item(6).Value
matcol8.Editable = False
oDocRec.MoveNext()
If oDocRec.EoF = True Then
totrow = totrow + 1
Oform.Freeze(False)
Exit For
End If
totrow = totrow + 1
Omatrix.AddRow(1)
Next i
Oform.Freeze(False)
Else
MessageBox.Show("Parameter is not updated for this item")
End If
End If -
I want to enter some value in a matrix
I enbled matrix with
oMatrix.AddRow()
but problem is
that - when I am inputing data in matrix fields , after pressing tab the value disappears
how can I resolve the problem?thts because your matrix's columns are not bound with any user or DB datatsource. alternatively , you will have to bind it with the columns of table to which you are saving the data.
regards,
Binita -
How to Write values in matrix and add Rows
hi all,
i am having a problem in retrieving values
for Combobox in Matrix.
one more thing is i am not able to write to the Matrix
even after adding rows by using oMatrix.Add()
pls help me
if possible any sample code of linking columns to datasource and popping values in combobox.
Regards
omOm,
You may want to look at the samle code that comes with the SAP Business One 2005A SDK with respect to the DI API. There is a sample that shows entering a sales order in an external VB.Net app and the populating a sales order rows and header in Business One. This may five you some help.
..\Program Files\SAP\SAP Business One SDK\Samples\COM DI\VB.NET\05.OrderAndInvoice
HTH,
Eddy -
SSRS 2008 - Matrix subtotals in rows (like in Excel)
Hello guys,
I have to develop report in following structure:
My best shot so far was creating matrix, but I don't know how to add the subtotal rows which are calculated as one row values divided by another.
Source data snippet:
Row Number
Column 1
Column 2
21
1
2
22
3
2
23
6
6
24
9
6
Desired output in report:
Row Number
Column 1
Column 2
21
1
2
22
3
2
23
6
6
Row no. 23/Row no. 22
2
3
24
9
6
Row no. 24/Row no. 22
3
3
I was able to create matrix with Row Number but cannot figure out how to add rows with subtotals as showed above.
Any suggestion would be greatly apprecited.
RoyHi Roy,
According to your description, you want to create some calculated rows, which stores the previous row value divided by a specified row value.
In Reporting Service, we can use matrix to group data by multiple fields or expressions in row and column groups. But it’s impossible to add a data row directly between two row groups. In this scenario, it’s also impossible to get the value of a specific
data row. So we can never make a data row divided by another data row. By the way, even you could add a row, when you use rownumber() function, the row number will increase with the added row. So your requirement can’t be achieved currently.
Reference:
Matrices (Report Builder and SSRS)
If you have any question, please feel free to ask.
Best regards,
Qiuyun Yu -
Matrix report with row field as "dates of months"
Hi all,
I have a matrix report that requires such a format:
Some database column -->
1 cell cell cell cell
2 null null null null
3
4
31 cell
now i cannot get the dates of the month in order of 1 to 31'st as column, if i give my database column datefield the records which are on following date are displayed but for the dates which dont have records, the cell fields should be null..
How would i do this.
Regards,
Sreekanth.Hi all,
I have a matrix report that requires such a format:
Some database column -->
1 cell cell cell cell
2 null null null null
3
4
31 cell
now i cannot get the dates of the month in order of 1 to 31'st as column, if i give my database column datefield the records which are on following date are displayed but for the dates which dont have records, the cell fields should be null..
How would i do this.
Regards,
Sreekanth. -
How to insert an empty row on a matrix with multiple loaded lines?
Hi.
I want to insert an empty row on my form's matrix. Currently I am using the <b>AddRow </b>method, as it is:
// C# - it's mandatory to give parameters to the method (=
oMatrix.AddRow(1,1)
But, when the matrix already has some rows (at least 1), the method <b>AddRow </b>inserts the new line as a copy of above line, then, I have to manually clear all cells.
Any idea on this?
Thanks in advance.If you matrix is bound to a dbDatasource you can insert a record in the dbdataspurce instead of using matrix.AddRow... If not only way to do it is by clearing the row after add
-
Matrix Select Row And Click()
Good Day
Experts:
I am in a bit of a quandry here today. I cannot figure out why I am unable to programatically acheive the 2 following actions:
1)Select a row in a Matrix
2)Click in a field to set cursor
I have the right-click Add Row event working. A new row is added to the Matrix. However, right now
the row I right-clicked on to add a new row is staying highlighted. I want to deselect that row and/or select the newly added row. Then click in a certain column in the new row.
The forum has many helpful suggestions but it seems I have tried al of them with no luck.
Here is what I have for the AddRow(after right-clicking on a row in the Matrix) and attempt at selecting a
row and clicking it:
MatlRFQMatrix.AddRow()
ClearMatrixDataSourceAdd(MatrixRowCount + 1)
PrevSeq = MatlRFQMatrix.Columns.Item("clHash").Cells.Item(MatlRFQMatrix.VisualRowCount - 1).Specific.value
PrevRFQSeq = MatlRFQMatrix.Columns.Item("clDocSeq").Cells.Item(MatlRFQMatrix.VisualRowCount - 1).Specific.value
MatlRFQMatrix.Columns.Item("clHash").Cells.Item(MatrixRowCount + 1).Specific.value = PrevSeq + 1
MatlRFQMatrix.Columns.Item("clDocNum").Cells.Item(MatrixRowCount + 1).Specific.Value = ReqNoPassed
MatlRFQMatrix.Columns.Item("clDocLine").Cells.Item(MatrixRowCount + 1).Specific.Value = ReqLinePassed
MatlRFQMatrix.Columns.Item("clDocSeq").Cells.Item(MatrixRowCount + 1).Specific.Value = PrevRFQSeq
MatlRFQMatrix.Columns.Item("clStatus").Cells.Item(MatrixRowCount + 1).Specific.Value = "Order"
Dim oMatrix As SAPbouiCOM.Matrix
oMatrix = MatlRFQForm.Items.Item("mtxMatRFQ").Specific
oMatrix.SelectRow(MatrixRowCount + 1, True, False)
MatlRFQMatrix.Columns.Item("clCardCd").Cells.Item(MatrixRowCount + 1).Click(SAPbouiCOM.BoCellClickType.ct_Regular)
Any ideas why I can't select a row or have a click sei in a column?
Thanks,
EdHi Ed,
on which event you are doing this coding.
It should be on right click After Event.
As well as you add the new row into the matrix, the visual row count increamented by one.
So insted of using Matrix.VisualRowCount+1 or matrix.VisualRowCount -1, you have to usae only and simply Matrix.VisualRowCount.
whats the value of MatrixRowCount. Is it a variable.
please try to more clear your code. -
Creating new row in a matrix by pressing the down arrow key
Hi all
i wish to cause a matrix to add rows when pressing on the down arrow key. can you provide me with the lines of code which achieve this requirement?
appreicate the help
YoavHi Yechiel,
I think you can capture the moment of the pressing the down arrow key. in that moment, you can utilize this code to add the line. I used DBDataSource. it's most easy and simple way to handle matrix, I think. I can't remember the character code of down arrow. But I think, you can find it easily.
oForm.DataSources.DBDataSources.Item("@DBS_CBP2").InsertRecord(position)
oForm.DataSources.DBDataSources.Item("@DBS_CBP2").Offset = oForm.DataSources.DBDataSources.Item("@DBS_CBP2").Offset + 1
oMatrix.AddRow()
Regards,
Hyunil Choi -
Deleting row in matrix.
Hello.
I have weird problem.
If I add some rows to matrix, and then delete rows the method with:
m_pMatrix->GetRowCount();
return the number of rows without delete.
For example:
If i have matrix with 5 rows, and I delete 2 rows, method with GetRowCount show me 5
What is wrong ?
I solved this problem with adding new variable, but why does it work wrong ?
Sorry for my english.
Regards
Kamil WydraHello.
Thank You for Your response.
I try that and it works.
Thanks again.
Regards
Kamil Wydra -
Delete Last Row in Matrix on SBO 2005
Hi,
Im using SAPB1 2005 SP1 with B1DE.
I've seen a post that indicates that the following code should delete a row from a matrix (even the last row) when using SBO 2005
I still find that all rows except last row of matrix are removed from the database.
<b>How do I delete the last row from the Del button event handler????</b>
I'm using
<i> [B1Listener(BoEventTypes.et_CLICK, false)]
public virtual void OnAfterClick(ItemEvent pVal)
bool ActionSuccess = pVal.ActionSuccess;
Form form = B1Connections.theAppl.Forms.Item(pVal.FormUID);
Item item = form.Items.Item("del");
Button button = ((Button)(item.Specific));
// ADD YOUR ACTION CODE HERE ...
int row;
Matrix oMtx = (Matrix)form.Items.Item("mtx_0").Specific;
DBDataSource oDBDS = (DBDataSource)form.DataSources.DBDataSources.Item("@SD_POOLCONTRCT_LINE");
row = oMtx.GetNextSelectedRow(0, BoOrderType.ot_SelectionOrder);
oMtx.DeleteRow(row);
if (oMtx.RowCount == 0)
oDBDS.RemoveRecord(0);
if ((form.Mode != BoFormMode.fm_ADD_MODE) | (form.Mode != BoFormMode.fm_UPDATE_MODE))
form.Mode = BoFormMode.fm_UPDATE_MODE;
}</i>Hi Ben,
[B1Listener(BoEventTypes.et_CLICK, false)]
public virtual void OnAfterClick(ItemEvent pVal)
bool ActionSuccess = pVal.ActionSuccess;
Form form = B1Connections.theAppl.Forms.Item(pVal.FormUID);
Item item = form.Items.Item("del");
Button button = ((Button)(item.Specific));
// ADD YOUR ACTION CODE HERE ...
int row;
Matrix oMtx = (Matrix)form.Items.Item("mtx_0").Specific;
DBDataSource oDBDS = (DBDataSource)form.DataSources.DBDataSources.Item("@SD_POOLCONTRCT_LINE");
Rest of your code will remain same.
I am making the modification here. I am using the RowCount property that gives me the address of the last row of the matrix.
<b>row = oMtx.RowCount;</b>
Every time this will return you the last row and that row will be deleted.
<b>row = oMtx.RowCount;</b>
oMtx.DeleteRow(row);
if (oMtx.RowCount == 0)
oDBDS.RemoveRecord(0);
if ((form.Mode != BoFormMode.fm_ADD_MODE) | (form.Mode != BoFormMode.fm_UPDATE_MODE))
form.Mode = BoFormMode.fm_UPDATE_MODE;
Regards,
Prashant -
Element-by-element multiplication of a vector with matrix rows
I want to element-by-element multiply a Vector with the rows of a Matrix ,in the most efficient way. Anybody knows if there is a sub vi for this in LW7.0 ?
(The Inputs are a Matrix; and a Vector with the same size as Matrix's # of columns ; the output is a Matrix with the same dimension as input Matrix. Every row of the output Matrix is the product of element-by-element multiplication of input vector with the correspondind input Matrix's row )
Thanks(Yes, the 2D linear evaluation is basically the same as the 1D evaluation except for the dimension if the array. NI could merge them into one and make the array input polymorphic with respect to size. )
I "think" you want a plain multiply (not a polynomial evaluation). You can do it (A) one row at a time or (B) one column at a time, but A might possibly be slightly more efficient. Do all three (including the one in the next message) and race them with your real data! Message Edited by altenbach on 03-14-2005 07:47 AM
LabVIEW Champion . Do more with less code and in less time .
Attachments:
MatrixTimesVector.gif 5 KB -
How to delete zero rows from a matrix?
Hi,
I have a 2D datamatrix and there are some zero rows. My original program should recognize all zero rows and delete them. How to do that?
I have tried with the Delete From Array function but no success. I also tried with the OpenG array functions but...no.
I attached a vi which simulates my problem. There is one zero row and I want to delete it and have a matrix without zero rows.
Kudos for any good help!
Solved!
Go to Solution.
Attachments:
DeleteZeroRows.vi 19 KBChristian_M wrote:
The idea was to give a hint that people try using their brain....
Stilll, I think your code is fundamentally flawed and will thus lead the student into a deep swamp.
Have you actually tried it with multiple rows of zeroes?
Since "delete from array" rearranges the array indices with each deletion, the code will break if there is more than one row to be deleted. For example if a row is already deleted and it needs to also delete the last row, it would try to delete a row that no longer exists. If a later row still exists, it will delete the wrong row.
Also, since NaN gets coerced to a valid index (2147483647), it's probably not such a good idea. "-1" would be a better choice. (Well, it's an unlikely implossible possibility in LabVIEW 32 bit, but still....)
I also don't understand your logic with "search array". You need to test all elements for zero.
LabVIEW Champion . Do more with less code and in less time .
Maybe you are looking for
-
Can anyone tell me the difference between these two: <i><b>if sy-subrc = 0. and if sy-subrc is initial.</b></i> Initial is not right statement to use but in my code when checking using initial, there is no syntax error, moreover the code was getting
-
HP Color LaserJet 1215/ 1210 series
Why does this and one other HP printer not have a driver for the MAC?? If there is going to be a driver for this model when is the MAC driver for this printer going to come out? Are there any other ways around it? I have just bought this printer only
-
BOS: Triggering Execution Services, Transaction Code: BOSMM
Hi, Triggering Execution Services: In the transaction code 'BOSMM - Subcontractor/Vendor Processing'. The screen is displayed as shown below. 1. Show/Hide Work Lists 2. Show Execution Services 3. Execution of Services (Post) 4. Object to be Planned
-
Every time I change to xcel, it send me to the sales site and asks me to pay again. Yet it clearly states I have the facility for 12 months??????????? Nort working at all>
-
How to install Windows Live Essentials 2012 without updating Live Mail from 2011 to 2012?
Hi! The title pretty much describes my issue: I'd like to install the Movie Maker from Essentials Package 2012. The installer would like to update my Live Mail from 2011 to 2012, which I don't like. Any suggestions? Best regards Werner