Update multiple rows in a grid with oTrans.Update()

I have multiple Dashboard where I usually have a button to update all rows at once with a value when the user clicked the button. So, when I click on the button with the code below, it changes the value in the grid. However, it only update one row at a time. I made sure that the BAQ has the ‘Allow updates of multiple rows’ checked. What am I doing wrong?

EpiUltraGrid myGrid = (EpiUltraGrid)csm.GetNativeControlReference("f8348326-b599-4a56-98a7-388f23c674c9");
foreach (Infragistics.Win.UltraWinGrid.UltraGridRow r in myGrid.Rows)
{
r.Cells["Column"].Value = false;
}
oTrans.Update();

Dont update the grid, if you dont have to… the EpiDataView and DataTable (underlying data) should be accessible to you via code.

1 Like

I tried to loop through the dataview with the code at the end of this post and it doesn,t update at all:

Yes it’s for a Dashboard and I’m not on the cloud

Im not sure if this will help you. I pulled the setRowModOnSelectedRows from Epicor’s way of doing it, this way it also supports it when you have group by… You might just need to tweak grid.Selected.Rows to just be grid.Rows for all (not just selected ones).

setRowModOnSelectedRows(false, mainGrid);
this.oTrans.Update();
this.oTrans.NotifyAll(EpiTransaction.NotifyType.DeleteRow, V_DB_APEPaymentStatusSummar_1View_Row);
MainController.AppControlPanel.HandleToolClick("RefreshTool", new Infragistics.Win.UltraWinToolbars.ToolClickEventArgs(MainController.MainToolManager.Tools["RefreshTool"], null));
private bool setRowModOnSelectedRows(bool onlyOneRec, Ice.Lib.Framework.EpiUltraGrid grid)
{
    bool success = true;
    bool useActiveRow = false;

    if (grid.Selected.Rows.Count == 0)
    {
        if (grid.ActiveRow != null)
        {
            useActiveRow = true;
        }
    }

    if (useActiveRow == false)
    {
        foreach (Infragistics.Win.UltraWinGrid.UltraGridRow row in grid.Selected.Rows)
        {
            Infragistics.Win.UltraWinGrid.UltraGridGroupByRow groupByRow = row as Infragistics.Win.UltraWinGrid.UltraGridGroupByRow;
            if (groupByRow == null) {
            	string sStatus = Convert.ToString(row.Cells["UD04_ShortChar01"].Value);
            	if (sStatus == "REJECTED") {
            		row.Cells["Calculated_MarkForDelete"].Value = true;
            	}
            }
        }
    }
    else
    {
        Infragistics.Win.UltraWinGrid.UltraGridRow singleRow = grid.ActiveRow;
    	string sStatus = Convert.ToString(singleRow.Cells["UD04_ShortChar01"].Value);
    	if (sStatus == "REJECTED") {
    		singleRow.Cells["Calculated_MarkForDelete"].Value = true;
    	}
    }

    return success;
}

Also your column must be updatable.

1 Like

I’m not sure I understand what this function is doing. I understand that I need to notify the system that the row should be updated by setting the ‘rowmod’ but your function is only setting the grid cells like me, isn’t it?

First the “Column” should be your real column name. Lets say it is “MyCoolCheckBox” once you got that, then make sure “MyCoolCheckBox” is an updatable column in the Updatable BAQ. Possibly even in the Dashboard, it doesnt have to be visible, but must be Updatable.

I found my problem. I had an advanced BPM update in my BAQ and I was only reading 1 row from the ttResults table… I added a foreach and verified for RowMod = ‘U’ and it now works great

I’ll try to see if the BeginEdit() and EndEdit() works well if I set the value inside that and set the RowMod to U too. Thanks !