How to Add a blank Row to existing EpiUltraGrid

Hello,

I keep running into little issues.
I have a Dashboard that has 2 BAQs attached.
If you click the top grid and hit refresh, it will pop up the parameters screen.
If you click the lower grid and hit refresh, it just refreshes that grid.
I found a way to select the top grid using: summaryGrid.Rows[0].Selected = true;

My problem is that sometimes if a filter is not selected correctly, it will have 0 rows in the top grid.
I was thinking that it might be easier to add a blank or dummy row before it tries to select the top grid.

Can anyone tell me the best way to add a row?

Any help is appreciated.

Thank!

Does anyone know how to do this?

Or a better way?

couldn’t you just see if it has rows then select the first one? I don’t really understand what you are trying to do. Could you elaborate more?

No. I have to be able to select the first row in order for the refresh to work correctly.

Unless you know how to make a specific grid active and selected without a row in it?

The problem is that the top grid has to be selected in order for the refresh to trigger the BAQ parameter pop up screen. If the other grid is active, then the refresh doesn’t trigger the parameter pop up.

UltraGridRow row = this.ultraGrid.DisplayLayout.Bands[0].AddNew();
row.Cells[0].Value = "data";
row.Cells[1].Value = "data";
row.Cells[2].Value = data;

You can do this to add a row

Hey,

I get this, any ideas what the using might be:

The type or namespace name ‘UltraGridRow’ could not be found (are you missing a using directive or an assembly reference?)

Add this to the top of your code:

using Infragistics.Win.UltraWinGrid;

It’s still a little unclear as to what you’re trying to do and this does not feel like a great solution.
Can you elaborate more?
If you just need to refresh all the grids, there’s a checkbox called “Enable Refresh All”. That will give you a button to click to refresh all of the grids.

The using got it to pass the check but now I get this error

Application Error

Exception caught in: Infragistics4.Win.UltraWinGrid.v12.2

Error Detail

Message: Row insertion not supported by this data source.
Program: Infragistics4.Win.UltraWinGrid.v12.2.dll
Method: AddNewHelper

Client Stack Trace

at Infragistics.Win.UltraWinGrid.UltraGridBand.AddNewHelper(RowsCollection rows)
at Infragistics.Win.UltraWinGrid.UltraGridBand.AddNew(Boolean calledFromAddNew)
at Infragistics.Win.UltraWinGrid.UltraGridBand.AddNew()
at Script.checkForZeroRowsInSummaryGrid()
at Script.btnRefresh_Click(Object sender, EventArgs args)
at System.Windows.Forms.Control.OnClick(EventArgs e)
at Infragistics.Win.Misc.UltraButtonBase.OnClick(EventArgs e)
at Ice.Lib.Framework.EpiButton.OnClick(EventArgs e)
at Infragistics.Win.Misc.UltraButton.OnMouseUp(MouseEventArgs e)
at Ice.Lib.Framework.EpiButton.OnMouseUp(MouseEventArgs e)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

I’m sure it’s not allowing it because your BAQ isn’t an updateable one.
You could try going into the query and making it updateable.

Ehh, that’s probably not true.
It’s could be because you don’t have a datasource attached or AllowAddNew is set to false on the band.

If I understand correctly you want the second BAQ to refresh based upon the selection in the first BAQ. If that is true you want to look at Publish and Subscribe, built in Dashboard functionality. You publish the column (key) in the first BAQ and then subscribe (filter) to that in the second BAQ. Search for Publish and Subscribe and it walks you through setting it up.

Hello,

Thank you for the suggestion (which have used to pass the dates from the first baq to the 2nd one) but that would not help.

My problem is:

  • If you have no rows in the first baq after the date parameters have created an empty selection, and hit the refresh button I created, it gives an out of bounds error. That happens because I have a piece of code that selects the 1st row of the first baq before trying to refresh. That code is there because if the 2nd baq is selected and you refresh, it doesn’t trigger the parameter pop-up from the first BAQ.
  • I have to use parameters in the 1st BAQ because it does calculations based on a subset of the data range slected by the 2 parameters (Start Date and End Date).

If this doesn’t make sense or you can think or a better way to accomplish what I am trying to do, please let me know. I am trying to learn how all this works as I go.

How do you change the AllowAddNew to true?

So you have customized the dashboard and put a button on there to refresh the first BAQ (grid) and also another button to refresh the second grid?

No,

Just the one button to Refresh. If there is a way to tell the button to refresh the first grid directly, that would probably do what is needed.

This is the line I have in the button_Click method that refreashes:

MainController.AppControlPanel.HandleToolClick(“RefreshTool”, new Infragistics.Win.UltraWinToolbars.ToolClickEventArgs(MainController.MainToolManager.Tools[“RefreshTool”], null));

So your just emulating the Refresh button on the toolbar, got it, and that updates the first BAQ after entering your Date parameters and sometimes no data can be returned. Then the second BAQ IS or IS NOT dependent on the first BAQs data and/or parameters being selected? And it sounds like you have other code doing something? What does that look like?

I have included a picture and the current code.

Please look it over and let me know if there are any questions.

The first thing is when you open the dashboard, it pops up the parameters for the first BAQ (Top grid). It is Start Date and End Date so that the first BAQ can run calculations on the filtered results.

The first BAQ id called: Sales_Gross_Margin_Summary
The Second is called: Sales_Gross_Margin
I have published 2 fields (Start Date and End Date) from the top grid and filter by them in the bottom grid to make sure the data is showing the same date range in both.

The search box ‘Company’ Filters both BAQs at the same time when someone types in the box. If they type something that causes the rows to be blank, it will pop up and tell them, then delete the last character typed and filter by that.

The refresh button is supposed to select the top grid and do a refresh. That will cause the BAQ parameters to pop up so you can select a new date range.

The reason for the line that tries and selects the 1st row in the top grid is because if the bottom grid is selected, the refresh does nothing.

Below is an image of the dashboard with most of the info deleted.

Below is the code I created to try and do what I need it to.

_________________________________________________________
using System;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Windows.Forms;
using Ice.BO;
using Ice.UI;
using Ice.Lib;
using Ice.Adapters;
using Ice.Lib.Customization;
using Ice.Lib.ExtendedProps;
using Ice.Lib.Framework;
using Ice.Lib.Searches;
using Ice.UI.FormFunctions;
using System.Linq; //Added for the search function SDH 2021-08-18
using Infragistics.Win.UltraWinGrid;

public class Script
{
	// ** Wizard Insert Location - Do Not Remove 'Begin/End Wizard Added Module Level Variables' Comments! **
	// Begin Wizard Added Module Level Variables **

	// End Wizard Added Module Level Variables **

	// Add Custom Module Level Variables Here **
	EpiUltraGrid summaryGrid;

	public void InitializeCustomCode()
	{
		// ** Wizard Insert Location - Do not delete 'Begin/End Wizard Added Variable Initialization' lines **
		// Begin Wizard Added Variable Initialization

		// End Wizard Added Variable Initialization

		// Begin Wizard Added Custom Method Calls

		this.txtCompany.TextChanged += new System.EventHandler(this.txtCompany_TextChanged);
		this.btnRefresh.Click += new System.EventHandler(this.btnRefresh_Click);
		summaryGrid = (EpiUltraGrid)csm.GetNativeControlReference("f3a0ad9e-a4c6-47cf-b20a-226017d67db9");
		
		// End Wizard Added Custom Method Calls
	}

	public void DestroyCustomCode()
	{
		// ** Wizard Insert Location - Do not delete 'Begin/End Wizard Added Object Disposal' lines **
		// Begin Wizard Added Object Disposal

		this.txtCompany.TextChanged -= new System.EventHandler(this.txtCompany_TextChanged);
		this.btnRefresh.Click -= new System.EventHandler(this.btnRefresh_Click);
		// End Wizard Added Object Disposal

		// Begin Custom Code Disposal

		// End Custom Code Disposal
	}

	// Below method is used to filter out companies dynamically
	private void txtCompany_TextChanged(object sender, System.EventArgs args)
	{
		var summaryEdv = (EpiDataView)(oTrans.EpiDataViews["V_MPD_Sales_Gross_Margin_Summary_1View"]);
		summaryEdv.dataView.RowFilter = "InvcHead_Company like '%" + txtCompany.Text + "%'";

		var detailsEdv = (EpiDataView)(oTrans.EpiDataViews["V_MPD_Sales_Gross_Margin_1View"]);
		detailsEdv.dataView.RowFilter = "InvcDtl_Company like '%" + txtCompany.Text + "%'";
		checkForZeroRowsInSummaryGrid();
	}

	// Below is the method I use to create a Refresh button
	private void btnRefresh_Click(object sender, System.EventArgs args)
	{
		checkForZeroRowsInSummaryGrid(); // Added to correct the search feature and also to fix the 0 rows because of Date parameter filtering.
		summaryGrid.Rows[0].Selected = true; // Added to get the top grid selected. Causing Issues when there are 0 rows because of BAQ Date parameters.
		// Below line accesses the refresh from the toolbar.
		MainController.AppControlPanel.HandleToolClick("RefreshTool", new Infragistics.Win.UltraWinToolbars.ToolClickEventArgs(MainController.MainToolManager.Tools["RefreshTool"], null));
	}

	// Below method fixes the company search returning 0 rows because nothing matches.
	private void checkForZeroRowsInSummaryGrid(){
		var modifiedSearchTerm = txtCompany.Text;
		if(summaryGrid.Rows.Count == 0){
			if(modifiedSearchTerm.Length > 0){
				modifiedSearchTerm = txtCompany.Text.Substring(0,txtCompany.Text.Length-1);	
				MessageBox.Show("Search term does not exist. \nSearch Term changed to: " + modifiedSearchTerm);
				txtCompany.Text = modifiedSearchTerm;
			}else{
				// This is where I was thinking of having it create a dummy row for the refresh to see.
			}
		}
	}
}

Hello,

Any thought on this?

I want to thank all of you on here for the time you are putting in on this to help me figure this issue out. I really appreciate it!

Couple quick questions first. The top baq is grouped/summarized by what, looks like customer? and then the bottom baq is the detail, like all the customer invoices/calculated SGM, to that summary line in the first baq, correct?

Yes.

The top is the summary grouped by customer and the bottom is the detailsused to create the top grid summary.

Sorry for all the questions, I was really trying to understand what you were trying to do. So I think you really want to use Publish and Subscribe but do not use a parameters in the BAQ (remove those), use a tracker on the dashboard. The general step would be 1. Add the first BAQ 2. Add a Tracker, to the first BAQ setting up controls for the Date 3. Setup first BAQ to publish the Customer and Date 4. Add second BAQ and filter (subscribe) to those published columns.