Dashboard Filter As You Type - Example Video

I was recently asked about a really old Youtube video I did showing a filter as you type in a dashboard. Looking back at my video I realized I did it a much harder way then I needed to. I made a new video showing how to add filter as you type in a customized dashboard.

13 Likes

Very cool!

Here is a code if people would like to copy paste.

  var partsEdv = (EpiDataView)(oTrans.EpiDataViews["VIEWNAME1"]);
	string filter = String.Format("FIELD like '%{0}%'",descriptionTb.Text);

	partsEdv.dataView.RowFilter = filter;
1 Like

Any idea how to do this with multiple fields (filters)? Iā€™m struggling to figure out the csharp.

// nevermind

private void DescriptionTb_TextChanged(object sender, System.EventArgs args)
{
var DescriptionEdv = (EpiDataView)(oTrans.EpiDataViews[ā€œV__kpPartSearchAuto_1Viewā€]);

string filter = String.Format("PartClass_Description like '%{0}%'",DescriptionTb.Text);

DescriptionEdv.dataView.RowFilter = filter;
}

private void PartNumTb_TextChanged(object sender, System.EventArgs args)
{
var partnumEdv = (EpiDataView)(oTrans.EpiDataViews["V__kpPartSearchAuto_1View"]);

string filter = String.Format("Part_PartNum like '%{0}%'",PartNumTb.Text);

partnumEdv.dataView.RowFilter = filter;
}

If you have multiple fields that you want to filer on you need to combine all the filters into a single string.
You would call a common method from all the textbox change events that creates the combined filter.

Hereā€™s a good example:

1 Like

Do you know how I can filter from a check box? I donā€™t think I can build that into string.

Calculated field is ā€œtrueā€ or ā€œfalseā€ based on case.

CASE
WHEN Part.PartDescription LIKE ā€˜%2P%ā€™
THEN ā€˜trueā€™
ELSE ā€˜falseā€™
END

Iā€™m not sure how to write a variation of the code to filter by an ā€œon clickā€ check box.

string filter = String.Format(ā€œCalculated_TwoPole = trueā€,epiCheckBoxC1.Text);

Here is my crappy solution. When box is checked, filter the calculated field by string.
Had to change my calculated field to string.

CASE
WHEN Part.PartDescription LIKE ā€˜%2P%ā€™
THEN ā€˜yepā€™
ELSE ā€˜nopeā€™
END

	private void TwoPoleChk_CheckedChanged(object sender, System.EventArgs args)
{
	var TwoPoleEdv = (EpiDataView)(oTrans.EpiDataViews["V__kpBreakerSearch_1View"]);
	System.Text.StringBuilder filter = new System.Text.StringBuilder();
	if(TwoPoleChk.Checked)
	{
		if (filter.Length > 0) filter.Append(" OR ");
		{
			filter.Append("Calculated_TwoPole = 'yep'");
		}
	}	
	TwoPoleEdv.dataView.RowFilter = filter.ToString();
}

Hi Carson - when I pen the Custom Object Explorer, I see two tabs UI Objects and Adapters. I do not have the Data tab. Using cloud version 2021.1, base 11.1.100.0.

Any suggestions?

Thanks in advance.

Are you customizing the tracker view or the deployed dashboard assembly? A lot of customizations tools are missing when customizing a dashboard tracker view.

I am customizing the tracker in dashboard development.

Beautiful piece of code @Carson !!

I applied it to a dashboard that I build and it worked first tryā€¦

I tried it on another dashboard and I get weird behaviorā€¦

The list starts to shorten as expected, and then when I click on an item in the list, the filter is removed and the list expands to full againā€¦ and the line that I selected is no longer selected

Iā€™ve tried it on a 3rd Dashboard with the same weird results

Do you or anyone have any suggestions on what may be causing this??

Iā€™ve done the usual Clear Client Cache

All good, I rebuilt the Dashboard from the ground up, works fine

@Carson , I think Iā€™ve found the problem, the weird behavior was only happening when I added the customization to a Dashboard that had row filters on it, when you deploy a Dashboard with row rules is creates two EDVā€™s

		this.V_TWG_Proc_Dash_Top_1View_Row = ((Ice.Lib.Framework.BAQDataView)(this.csm.GetGlobalInstance("V_TWG_Proc_Dash_Top_1View_Row")));
		this.V_TWG_Proc_Dash_Top_1View1_Row = ((Ice.Lib.Framework.FilteredBAQDataView)(this.csm.GetGlobalInstance("V_TWG_Proc_Dash_Top_1View1_Row")));

image

One for the initial load of the data and one to apply the row rules

The Grid gets bound to the 2nd edv

I tried changing the binding of the grid back to the 1st edv and that fixes the filter problem but the row rules disappear

Has anyone had the same behavior and does anyone know a fix??

Or is there a way to develop the row rules in the dashboard customization?

Hi,

Code works perfect for filtering. But one issue apears, if I use row rules to color cels by values and try to use filter as you type issue apears when you clean the text box, row rules clears out and color disapears. Any ideas how to keep them working in paralel together?
Before filtering:
image
After cleaning filter:
image

Thanks for sharing this!

I followed the instructions and examples above to get multiple filters working (filtering both multiple fields on a grid and multiple criteria on each field, each separated by a space), and figured Iā€™d share the code in case anyone else finds it useful.

Hereā€™s the result:

LivePartSearch

I moved most of the code out into a couple of functions, that can just be copy/pasted with minimal updates to field names all in one place. (Having just the few lines to update all in one place certainly helps when you change something on the dashboard and re-deploy, which requires completely redoing the customization.)

	private void update_grid_filter()
	{
		// Update name of EpiDataView from Data Browser, replacing "V_BS_PartSearch2_1View" below
		EpiDataView partsEdv = (EpiDataView)(oTrans.EpiDataViews["V_BS_PartSearch2_1View"]);
		
		string filter = "";
		
		// Add each filter field in sequence.  Each call returns new filter
		// 	2nd argument is name of control on the form
		//	3rd argument is name of the field in the EpiDataView
		filter = add_to_filter(filter, epiTextBoxC1.Text, "Part_PartNum");
		filter = add_to_filter(filter, epiTextBoxC2.Text, "Part_PartDescription");
		filter = add_to_filter(filter, epiTextBoxC3.Text, "Vendor1_VendorID");
		filter = add_to_filter(filter, epiTextBoxC4.Text, "Vendor1_Name");
		filter = add_to_filter(filter, epiTextBoxC5.Text, "PartXRefVend1_VendPartNum");
		filter = add_to_filter(filter, epiTextBoxC6.Text, "Part_MfgComment");

		// Apply full filter to grid
		partsEdv.dataView.RowFilter = filter;

	}

	private string add_to_filter(string cur_filter, string new_filter, string column_name)
	{
		// function for building up the overall filter string for the DataView
		if (!(string.IsNullOrEmpty(new_filter)))
		{
			string[] substrings = new_filter.Split(' ');
			foreach (var sub in substrings)
			{	
				// if there's already a filter, add to it with 'AND'; otherwise start fresh
				if(cur_filter.Length > 0) cur_filter+=(" AND ");  
				cur_filter+=(column_name + " Like '%" + sub + "%'");
			}
		}
		return cur_filter;
	}

Then you just need to update that series of lines that build up the filter one field at a time, e.g. filter = add_to_filter(filter, epiTextBoxC1.Text, "Part_PartNum"); with the names of the controls and columns that you want to filter on.

And call update_grid_filter() any time the value of the fields changes. (I also added in a ā€˜Clear Allā€™ button that wipes out all of the search field contents, as a minor convenience.)

	private void epiTextBoxC1_ValueChanged(object sender, System.EventArgs args)
	{
		update_grid_filter();
	}

	private void epiTextBoxC2_ValueChanged(object sender, System.EventArgs args)
	{
		update_grid_filter();
	}

	private void epiTextBoxC3_ValueChanged(object sender, System.EventArgs args)
	{
		update_grid_filter();
	}

	private void epiTextBoxC4_ValueChanged(object sender, System.EventArgs args)
	{
		update_grid_filter();
	}

	private void epiTextBoxC5_ValueChanged(object sender, System.EventArgs args)
	{
		update_grid_filter();
	}

	private void epiTextBoxC6_ValueChanged(object sender, System.EventArgs args)
	{
		update_grid_filter();
	}

	private void epiButtonC1_Click(object sender, System.EventArgs args)
	{
		epiTextBoxC1.Text = "";
		epiTextBoxC2.Text = "";
		epiTextBoxC3.Text = "";
		epiTextBoxC4.Text = "";
		epiTextBoxC5.Text = "";
		epiTextBoxC6.Text = "";
	}
2 Likes

@bsiller Amazing piece of code!!
Love it how you can do a partial search separated by a space from any field

I have spent way too much time trying to figure this out in E9. Am willing to pay someone who can help me via a Zoom meeting.

Anybody care to help?

The trouble I am having is referring to objects because the Data explorer does not show up in E9 and I donā€™t know how to refer to the variables.

I have lots of programming experience, but not so much in Epicor.