Remove a sort on a dashboard (restore the BAQ's sort)

Thanks,

This works on 10.2.200.7 as well.

Do you have to do this every time you open the dashboard?

I’d guess you should use “Save Layouts” after using that trick.

You do this trick in Dashboard menu and then Deploy Dashboard.

1 Like

No,

Only did it once in developer mode and has worked with the default sort from the query since.

I did not do a save layouts.

Opened Dashboard in developer mode

Group by offending column

Remove Group

Refresh

Save dashboard

So far seems to be working as intended everywhere deployed.

I need to have multiple sort criteria. So this won’t work for me. @Chris_Conn, can I sort the dashboard by multiple fields using your customization?

Yes, you can add multiple sorts to an UltraGrid.
https://www.infragistics.com/community/forums/f/ultimate-ui-for-windows-forms/93046/multi-sorted-columns-programmatically-ultragrid

Will it keep the sorting even if they hit refresh?

@Chris_Conn

@Chris_Conn , but how do I reference the grid and event that you posted within epicor? I can’t seem to find the event that I should run that code you posted.

The link you posted shows the code below. When I try to add a system event handler for the intializelayout event for Infragistics.Win.UltraWinGrid.UltraGrid it says “Error: CS0123 - line 45 (136) - No overload for ‘plannedworkgrid_InitializeLayout’ matches delegate ‘System.EventHandler’.”

This is what I have so far

using System;
using System.ComponentModel;
using System.Data;
using System.Drawing;
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 Infragistics.Win.UltraWinGrid;
using Infragistics.Shared;
using Infragistics.Win;
using System.Diagnostics;

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 **
Infragistics.Win.UltraWinGrid.UltraGrid plannedworkgrid;
// Add Custom Module Level Variables Here **
	
public void InitializeCustomCode()
{
	// ** Wizard Insert Location - Do not delete 'Begin/End Wizard Added Variable Initialization' lines **
	// Begin Wizard Added Variable Initialization
	
		// Add Event Handler Code
	
	plannedworkgrid = (Infragistics.Win.UltraWinGrid.UltraGrid)csm.GetNativeControlReference("18279620-4c0e-401e-89c1-5a0a8081f639");
	

	// End Wizard Added Variable Initialization
	this.plannedworkgrid.InitializeLayout += new System.EventHandler(this.plannedworkgrid_InitializeLayout);
	// Begin Wizard Added Custom Method Calls

	// 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.plannedworkgrid.InitializeLayout -= new System.EventHandler(this.plannedworkgrid_InitializeLayout);

	// End Wizard Added Object Disposal

	// Begin Custom Code Disposal
	// End Custom Code Disposal
}



private void plannedworkgrid_InitializeLayout(object sender, Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs e)
{

	// InitializeLayout gets fired for the UltraGrid's layout as well as when printing.

	e.Layout.Appearance.BackColor = Color.Red;

}

}

It doesnt expect a generic System.EventHandler, it expects the handler specific to that event:
InitializeLayoutEventHandler

So would I just write this?

this.plannedworkgrid.InitializeLayout += new EventHandler(this.plannedworkgrid_InitializeLayout);

this.plannedworkgrid.InitializeLayout -= new EventHandler(this.plannedworkgrid_InitializeLayout);

When I do I get this message. What Am I doing wrong?

Error: CS0123 - line 45 (136) - No overload for ‘plannedworkgrid_InitializeLayout’ matches delegate ‘System.EventHandler’
Error: CS0123 - line 53 (144) - No overload for ‘plannedworkgrid_InitializeLayout’ matches delegate ‘System.EventHandler’

@Chris_Conn

this.plannedworkgrid.InitializeLayout += new InitializeLayoutEventHandler(this.plannedworkgrid_InitializeLayout);

@Chris_Conn that compiles nicely. Thank you for your time and effort!

For some reason it still does not sort… Am I doing anything wrong in my code? Any explanation would be awesome.

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 **
	Infragistics.Win.UltraWinGrid.UltraGrid plannedworkgrid;

	public void InitializeCustomCode()
	{
		
		plannedworkgrid = (Infragistics.Win.UltraWinGrid.UltraGrid)csm.GetNativeControlReference("18279620-4c0e-401e-89c1-5a0a8081f639");
		this.plannedworkgrid.InitializeLayout += new InitializeLayoutEventHandler(this.plannedworkgrid_InitializeLayout);
	}

	public void DestroyCustomCode()
	{

	}
	private void plannedworkgrid_InitializeLayout(object sender, Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs e)
	{

		// InitializeLayout gets fired for the UltraGrid's layout as well as when printing.
		    UltraGridLayout layout = e.Layout;
		    UltraGridBand band = layout.Bands[0];
		    UltraGridOverride ov = layout.Override;
		    band.SortedColumns.Add("JobAsmbl_PartNum", false);
	}


}

@hkeric.wci , I have seen some of your grid filtering, do you have any examples of how to do grid sorting?

Is there a reason not to just do it in the BAQ before it gets to your dashboard?

This post was originally created to call out an issue with dashboards where it ignores the BAQ sorting. That is what is happening and so I am trying to fix it via code.

The issue was resolved by getting rid of the sort that was applied to the dashboard then saved. That was Chris’s original fix on post 14. The code you posted didn’t use that code. You are attempting to re-create the sorting in the BAQ.

It’s probably going to be an easier fix to add the row numbers in the BAQ and then have that column available to sort by.

1 Like

@Banderson I went back to the BAQ to ensure my sorting was working only to find that it isn’t even sorting by what I chose. I will start a new topic.