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.

10 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;

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();
}