Hi,
Please try the attached Aspose.Grid.Web version v2.0.1.2005.
We provide an interface named ICustomFilter to customize filter.
Please try the following code:<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
// initialize
WebWorksheet sheet = GridWeb1.WebWorksheets[0];
int lintCounter = 0;
sheet.Cells[0, 0].StringValue = "Investor Name";
sheet.Cells[0, 1].StringValue = "Fund Name";
sheet.Cells[0, 2].StringValue = "ADR Register";
sheet.Cells[0, 3].StringValue = "City";
while (lintCounter < 1000)
{
sheet.Cells[lintCounter + 1, 0].StringValue = "Investor " + lintCounter % 10;
sheet.Cells[lintCounter + 1, 1].StringValue = "Fund " + lintCounter % 5;
sheet.Cells[lintCounter + 1, 2].PutValue(lintCounter % 2);
sheet.Cells[lintCounter + 1, 3].StringValue = "City " + lintCounter;
lintCounter++;
}
GridWeb1.WebWorksheets[0].RowFilter.CustomFilter(0, new CustomFilter());
}
}
public class CustomFilter : ICustomFilter
{
#region ICustomFilter Members
public IDictionary GetFilterValueList(WebWorksheet sheet, int columnIndex)
{
// specify the filter value list for each column.
IDictionary dt = new SortedList();
switch (columnIndex)
{
case 0:
dt.Add("Investor 0", 0);
dt.Add("Investor 1", 1);
dt.Add("Investor 2", 2);
dt.Add("Investor 3", 3);
break;
case 1:
dt.Add("Fund 0", 0);
dt.Add("Fund 1", 1);
dt.Add("Fund 2", 2);
dt.Add("Fund 3", 3);
break;
default:
break;
}
return dt;
}
public void FilterRows(WebWorksheet sheet, int columnIndex, int filterIndex)
{
// you must provide new data to the worksheet by column index and filter index.
sheet.Cells.Clear();
int lintCounter = 0;
int rowIndex = 1;
sheet.Cells[0, 0].StringValue = "Investor Name";
sheet.Cells[0, 1].StringValue = "Fund Name";
sheet.Cells[0, 2].StringValue = "ADR Register";
sheet.Cells[0, 3].StringValue = "City";
while (lintCounter < 1000)
{
if (columnIndex == 0 && lintCounter % 10 == filterIndex ||
columnIndex == 1 && lintCounter % 5 == filterIndex ||
filterIndex == -1)
{
sheet.Cells[rowIndex, 0].StringValue = "Investor " + lintCounter % 10;
sheet.Cells[rowIndex, 1].StringValue = "Fund " + lintCounter % 5;
sheet.Cells[rowIndex, 2].PutValue(lintCounter % 2);
sheet.Cells[rowIndex, 3].StringValue = "City " + lintCounter;
rowIndex++;
}
lintCounter++;
}
}
#endregion
}
Thank you.