aspnet-116762-components-pivot-grid-examples-data-shaping-how-to-replace-default-filter-items-with-custom-ones.md
This example shows how to replace default items with custom ones. For example, if you have too many items, it is convenient to group them based upon certain criteria and displaying group items in a filter popup. Handle the ASPxPivotGrid.CustomFilterPopupItems event to remove default items and add group items instead. To apply a filter based upon the selected by end-users, handle the ASPxPivotGrid.FieldFilterChanging event.
using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary;
using System.IO;
using System.Data;
using DevExpress.Web.ASPxPivotGrid;
using DevExpress.XtraPivotGrid;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e) {
ASPxPivotGrid1.DataSource = CreateCustomDataTable();
if (!IsPostBack && !IsCallback) {
PivotGridField fieldQuantity = new PivotGridField("Quantity", PivotArea.DataArea);
PivotGridField fieldProductName = new PivotGridField("ProductName", PivotArea.RowArea);
PivotGridField fieldDate = new PivotGridField("Date", PivotArea.ColumnArea);
fieldDate.GroupInterval = PivotGroupInterval.Date;
ASPxPivotGrid1.Fields.AddField(fieldProductName);
ASPxPivotGrid1.Fields.AddField(fieldDate);
ASPxPivotGrid1.Fields.AddField(fieldQuantity);
}
new CustomFilterRanges(ASPxPivotGrid1, ASPxPivotGrid1.Fields["ProductName"]).AddEvents();
new CustomFilterRanges(ASPxPivotGrid1, ASPxPivotGrid1.Fields["Date"]).AddEvents();
}
DataTable CreateCustomDataTable() {
DataTable customDataTable = new DataTable("Shopping");
customDataTable.Columns.Add("Quantity", typeof(float));
customDataTable.Columns.Add("Price", typeof(float));
customDataTable.Columns.Add("ProductName", typeof(string));
customDataTable.Columns.Add("Date", typeof(DateTime));
customDataTable.Rows.Add(5.0, 50.0, null, DateTime.Today.AddYears(-1).AddMonths(-1));
customDataTable.Rows.Add(10.0, 31.0, null, DateTime.Today.AddYears(-1).AddMonths(-1));
customDataTable.Rows.Add(3.0, 30.0, null, DateTime.Today.AddYears(-1).AddMonths(-1));
customDataTable.Rows.Add(3.5, 230.0, "Bananas", DateTime.Today.AddYears(-1).AddMonths(-1));
customDataTable.Rows.Add(5.0, 50.0, "Apples", DateTime.Today.AddDays(-8));
customDataTable.Rows.Add(10.0, 31.0, "Peaches", DateTime.Today.AddDays(-8));
customDataTable.Rows.Add(3.0, 30.0, "Lemons", DateTime.Today.AddDays(-8));
customDataTable.Rows.Add(3.5, 230.0, "Bananas", DateTime.Today.AddDays(-8));
customDataTable.Rows.Add(5.0, 52.0, "Apples", DateTime.Today.AddDays(-7));
customDataTable.Rows.Add(1.0, 33.0, "Peaches", DateTime.Today.AddDays(-7));
customDataTable.Rows.Add(2.0, 32.0, "Lemons", DateTime.Today.AddDays(-7));
customDataTable.Rows.Add(2.3, 250.20, "Bananas", DateTime.Today.AddDays(-7));
customDataTable.Rows.Add(5.0, 50.0, "Apples", DateTime.Today.AddDays(-6));
customDataTable.Rows.Add(10.0, 31.0, "Peaches", DateTime.Today.AddDays(-6));
customDataTable.Rows.Add(3.0, 30.0, "Lemons", DateTime.Today.AddDays(-6));
customDataTable.Rows.Add(3.5, 230.0, "Bananas", DateTime.Today.AddDays(-6));
customDataTable.Rows.Add(5.0, 52.0, "Apples", DateTime.Today.AddDays(-2));
customDataTable.Rows.Add(1.0, 33.0, "Peaches", DateTime.Today.AddDays(-2));
customDataTable.Rows.Add(2.0, 32.0, "Lemons", DateTime.Today.AddDays(-2));
customDataTable.Rows.Add(2.3, 250.20, "Bananas", DateTime.Today.AddDays(-2));
customDataTable.Rows.Add(1.0, 55.0, "Apples", DateTime.Today.AddDays(-1));
customDataTable.Rows.Add(2.0, 38.0, "Peaches", DateTime.Today.AddDays(-1));
customDataTable.Rows.Add(1.0, 36.0, "Lemons", DateTime.Today.AddDays(-1));
customDataTable.Rows.Add(2.0, 55.0, "Apples", DateTime.Today);
customDataTable.Rows.Add(2.0, 39.0, "Peaches", DateTime.Today);
customDataTable.Rows.Add(1.0, 37.0, "Lemons", DateTime.Today);
customDataTable.Rows.Add(3.5, 270.30, "Bananas", DateTime.Today);
customDataTable.Rows.Add(2.0, 55.0, "Apples", DateTime.Today.AddDays(1));
customDataTable.Rows.Add(3.0, 40.5, "Peaches", DateTime.Today.AddDays(1));
customDataTable.Rows.Add(4.2, 290.8, "Bananas", DateTime.Today.AddDays(1));
customDataTable.Rows.Add(10.0, 56.0, "Apples", DateTime.Today.AddMonths(1));
customDataTable.Rows.Add(1.0, 41.0, "Peaches", DateTime.Today.AddMonths(1));
customDataTable.Rows.Add(2.0, 39.0, "Lemons", DateTime.Today.AddMonths(1));
customDataTable.Rows.Add(1.5, 290.30, "Bananas", DateTime.Today.AddMonths(1));
customDataTable.Rows.Add(10.0, 56.0, "Apples", DateTime.Today.AddMonths(1).AddDays(1));
customDataTable.Rows.Add(1.0, 41.0, "Peaches", DateTime.Today.AddMonths(1).AddDays(1));
customDataTable.Rows.Add(2.0, 39.0, "Lemons", DateTime.Today.AddMonths(1).AddDays(1));
customDataTable.Rows.Add(1.5, 290.30, "Bananas", DateTime.Today.AddMonths(1).AddDays(1));
customDataTable.Rows.Add(5.0, 57.2, "Apples", DateTime.Today.AddYears(1));
customDataTable.Rows.Add(3.0, 42.0, "Peaches", DateTime.Today.AddYears(1));
customDataTable.Rows.Add(1.0, 43.0, "Lemons", DateTime.Today.AddYears(1));
customDataTable.Rows.Add(1.2, 295.30, "Bananas", DateTime.Today.AddYears(1));
return customDataTable;
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Collections;
using DevExpress.XtraPivotGrid.Data;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary;
using System.IO;
using System.Web.UI.WebControls;
using DevExpress.Web.ASPxPivotGrid;
/// <summary>
/// Summary description for GroupedFilterPopupItem
/// </summary>
public class CustomFilterRanges {
string[] stringRanges = new string[] { "A-G", "H-P", "Q-Z" };
string otherGroupName = "Other";
PivotGridField targetField;
ASPxPivotGrid pivot;
public CustomFilterRanges(ASPxPivotGrid pivot, PivotGridField field) {
this.pivot = pivot;
targetField = field;
}
public void AddEvents() {
pivot.CustomFilterPopupItems +=new EventHandler<PivotCustomFilterPopupItemsEventArgs>(pivot_CustomFilterPopupItems);
pivot.FieldFilterChanging +=new PivotFieldFilterChangingEventHandler(pivot_FieldFilterChanging);
}
public void Detach() {
pivot.CustomFilterPopupItems -= pivot_CustomFilterPopupItems;
pivot.FieldFilterChanging -= pivot_FieldFilterChanging;
}
void pivot_FieldFilterChanging(object sender, PivotFieldFilterChangingEventArgs e) {
if (Equals(e.Field, targetField))
this.ReplaceRangesByItems(e);
}
void pivot_CustomFilterPopupItems(object sender, PivotCustomFilterPopupItemsEventArgs e) {
if (Equals(e.Field, targetField))
this.ReplaceItemsByCustomRanges(e.Items);
}
void ReplaceItemsByCustomRanges(IList<PivotGridFilterItem> filterItemsCollection) {
Dictionary<string, List<object>> customGroups = GetCustomRanges(filterItemsCollection);
PopulateFilterPopupWithCustomRanges(filterItemsCollection, customGroups);
}
Dictionary<string, List<object>> GetCustomRanges(IEnumerable<PivotGridFilterItem> filterItemsCollection) {
Dictionary<string, List<object>> ranges = new Dictionary<string, List<object>>();
foreach (PivotGridFilterItem item in filterItemsCollection) {
if (item.IsBlank) continue;
string groupValue = GetGroupByItem(item);
if (!ranges.Keys.Contains(groupValue))
ranges.Add(groupValue, new List<object>());
ranges[groupValue].Add(item);
}
return ranges;
}
void PopulateFilterPopupWithCustomRanges(IList<PivotGridFilterItem> filterItemsCollection, Dictionary<string, List<object>> customGroups) {
RemoveNonBlankFilterItems(filterItemsCollection);
foreach (string key in customGroups.Keys)
filterItemsCollection.Add(new PivotGridFilterItem(key, key, IsItemsChecked(customGroups[key]), IsGroupVisible(customGroups[key])));
}
void RemoveNonBlankFilterItems(IList<PivotGridFilterItem> filterItemsCollection) {
for (int i = filterItemsCollection.Count - 1; i >= 0; --i)
if (!filterItemsCollection[i].IsBlank) filterItemsCollection.RemoveAt(i);
}
string GetGroupByDisplayText(string itemText) {
foreach (string key in stringRanges)
if (IsValueInStringInterval(key, itemText))
return key;
return otherGroupName;
}
void ReplaceRangesByItems(PivotFieldFilterChangingEventArgs e) {
List<object> currentRanges = new List<object>(e.Values);
e.Values.Clear();
foreach (object value in e.Field.GetUniqueValues())
if (currentRanges.Contains(GetGroupByValue(value)))
e.Values.Add(value);
}
string GetGroupByItem(PivotGridFilterItem item) {
return targetField.ActualDataType == typeof(DateTime) ? GetGroupByDate((DateTime)item.Value) : GetGroupByDisplayText(item.Text);
}
string GetGroupByValue(object value) {
return targetField.ActualDataType == typeof(DateTime) ? GetGroupByDate((DateTime)value) : GetGroupByDisplayText(targetField.GetDisplayText(value));
}
bool IsValueInStringInterval(string range, string item) {
string[] rangeBounds = range.Split('-');
string itemUpper = item.ToUpper();
return itemUpper.Substring(0, System.Math.Min(rangeBounds[0].Length, itemUpper.Length)).CompareTo(rangeBounds[0].ToUpper()) >= 0 &&
itemUpper.Substring(0, System.Math.Min(rangeBounds[1].Length, itemUpper.Length)).CompareTo(rangeBounds[1].ToUpper()) <= 0;
}
string GetGroupByDate(DateTime itemDate) {
DateTime lastWeekFirstDay = DateTime.Now.AddDays(-6 - (int)DateTime.Now.DayOfWeek);
if (itemDate <= lastWeekFirstDay.AddDays(-1))
return "Earlier";
if (itemDate >= lastWeekFirstDay && itemDate <= lastWeekFirstDay.AddDays(6))
return "Last Week";
if (itemDate >= DateTime.Now.AddDays(-(int)DateTime.Now.DayOfWeek) && itemDate < DateTime.Today)
return "This Week";
if (itemDate == DateTime.Today)
return "Today";
if (itemDate > DateTime.Today)
return "Later";
return otherGroupName;
}
bool IsGroupVisible(List<object> items) {
foreach (PivotGridFilterItem filterItem in items)
if (filterItem.IsVisible) return true;
return false;
}
bool IsItemsChecked(List<object> items) {
foreach (PivotGridFilterItem filterItem in items)
if (filterItem.IsChecked == false) return false;
return true;
}
}
<%@ Page Title="Home Page" Language="C#" AutoEventWireup="true"
CodeFile="Default.aspx.cs" Inherits="_Default" %>
<%@ Register assembly="DevExpress.Web.ASPxPivotGrid.v13.1, Version=13.1.0.0, Culture=neutral, PublicKeyToken=79868b8147b5eae4" namespace="DevExpress.Web.ASPxPivotGrid" tagprefix="dx" %>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<title>Demo</title>
</head>
<body>
<h2>
Custom filter range sample </h2>
<form id="form1" runat="server">
<div>
<dx:ASPxPivotGrid ID="ASPxPivotGrid1" runat="server">
</dx:ASPxPivotGrid>
</div>
<input runat="server" type="hidden" name="filterRanges" id="filterRanges" value="" />
</form>
</body>
</html>
Imports Microsoft.VisualBasic
Imports System
Imports System.Collections.Generic
Imports System.Linq
Imports System.Web
Imports System.Collections
Imports DevExpress.XtraPivotGrid.Data
Imports System.Runtime.Serialization
Imports System.Runtime.Serialization.Formatters.Binary
Imports System.IO
Imports System.Web.UI.WebControls
Imports DevExpress.Web.ASPxPivotGrid
''' <summary>
''' Summary description for GroupedFilterPopupItem
''' </summary>
Public Class CustomFilterRanges
Private stringRanges() As String = { "A-G", "H-P", "Q-Z" }
Private otherGroupName As String = "Other"
Private targetField As PivotGridField
Private pivot As ASPxPivotGrid
Public Sub New(ByVal pivot As ASPxPivotGrid, ByVal field As PivotGridField)
Me.pivot = pivot
targetField = field
End Sub
Public Sub AddEvents()
AddHandler pivot.CustomFilterPopupItems, AddressOf pivot_CustomFilterPopupItems
AddHandler pivot.FieldFilterChanging, AddressOf pivot_FieldFilterChanging
End Sub
Public Sub Detach()
RemoveHandler pivot.CustomFilterPopupItems, AddressOf pivot_CustomFilterPopupItems
RemoveHandler pivot.FieldFilterChanging, AddressOf pivot_FieldFilterChanging
End Sub
Private Sub pivot_FieldFilterChanging(ByVal sender As Object, ByVal e As PivotFieldFilterChangingEventArgs)
If Equals(e.Field, targetField) Then
Me.ReplaceRangesByItems(e)
End If
End Sub
Private Sub pivot_CustomFilterPopupItems(ByVal sender As Object, ByVal e As PivotCustomFilterPopupItemsEventArgs)
If Equals(e.Field, targetField) Then
Me.ReplaceItemsByCustomRanges(e.Items)
End If
End Sub
Private Sub ReplaceItemsByCustomRanges(ByVal filterItemsCollection As IList(Of PivotGridFilterItem))
Dim customGroups As Dictionary(Of String, List(Of Object)) = GetCustomRanges(filterItemsCollection)
PopulateFilterPopupWithCustomRanges(filterItemsCollection, customGroups)
End Sub
Private Function GetCustomRanges(ByVal filterItemsCollection As IEnumerable(Of PivotGridFilterItem)) As Dictionary(Of String, List(Of Object))
Dim ranges As New Dictionary(Of String, List(Of Object))()
For Each item As PivotGridFilterItem In filterItemsCollection
If item.IsBlank Then
Continue For
End If
Dim groupValue As String = GetGroupByItem(item)
If (Not ranges.Keys.Contains(groupValue)) Then
ranges.Add(groupValue, New List(Of Object)())
End If
ranges(groupValue).Add(item)
Next item
Return ranges
End Function
Private Sub PopulateFilterPopupWithCustomRanges(ByVal filterItemsCollection As IList(Of PivotGridFilterItem), ByVal customGroups As Dictionary(Of String, List(Of Object)))
RemoveNonBlankFilterItems(filterItemsCollection)
For Each key As String In customGroups.Keys
filterItemsCollection.Add(New PivotGridFilterItem(key, key, IsItemsChecked(customGroups(key)), IsGroupVisible(customGroups(key))))
Next key
End Sub
Private Sub RemoveNonBlankFilterItems(ByVal filterItemsCollection As IList(Of PivotGridFilterItem))
For i As Integer = filterItemsCollection.Count - 1 To 0 Step -1
If (Not filterItemsCollection(i).IsBlank) Then
filterItemsCollection.RemoveAt(i)
End If
Next i
End Sub
Private Function GetGroupByDisplayText(ByVal itemText As String) As String
For Each key As String In stringRanges
If IsValueInStringInterval(key, itemText) Then
Return key
End If
Next key
Return otherGroupName
End Function
Private Sub ReplaceRangesByItems(ByVal e As PivotFieldFilterChangingEventArgs)
Dim currentRanges As New List(Of Object)(e.Values)
e.Values.Clear()
For Each value As Object In e.Field.GetUniqueValues()
If currentRanges.Contains(GetGroupByValue(value)) Then
e.Values.Add(value)
End If
Next value
End Sub
Private Function GetGroupByItem(ByVal item As PivotGridFilterItem) As String
If targetField.ActualDataType Is GetType(DateTime) Then
Return GetGroupByDate(CDate(item.Value))
Else
Return GetGroupByDisplayText(item.Text)
End If
End Function
Private Function GetGroupByValue(ByVal value As Object) As String
If targetField.ActualDataType Is GetType(DateTime) Then
Return GetGroupByDate(CDate(value))
Else
Return GetGroupByDisplayText(targetField.GetDisplayText(value))
End If
End Function
Private Function IsValueInStringInterval(ByVal range As String, ByVal item As String) As Boolean
Dim rangeBounds() As String = range.Split("-"c)
Dim itemUpper As String = item.ToUpper()
Return itemUpper.Substring(0, System.Math.Min(rangeBounds(0).Length, itemUpper.Length)).CompareTo(rangeBounds(0).ToUpper()) >= 0 AndAlso itemUpper.Substring(0, System.Math.Min(rangeBounds(1).Length, itemUpper.Length)).CompareTo(rangeBounds(1).ToUpper()) <= 0
End Function
Private Function GetGroupByDate(ByVal itemDate As DateTime) As String
Dim lastWeekFirstDay As DateTime = DateTime.Now.AddDays(-6 - CInt(Fix(DateTime.Now.DayOfWeek)))
If itemDate <= lastWeekFirstDay.AddDays(-1) Then
Return "Earlier"
End If
If itemDate >= lastWeekFirstDay AndAlso itemDate <= lastWeekFirstDay.AddDays(6) Then
Return "Last Week"
End If
If itemDate >= DateTime.Now.AddDays(-CInt(Fix(DateTime.Now.DayOfWeek))) AndAlso itemDate < DateTime.Today Then
Return "This Week"
End If
If itemDate = DateTime.Today Then
Return "Today"
End If
If itemDate > DateTime.Today Then
Return "Later"
End If
Return otherGroupName
End Function
Private Function IsGroupVisible(ByVal items As List(Of Object)) As Boolean
For Each filterItem As PivotGridFilterItem In items
If filterItem.IsVisible Then
Return True
End If
Next filterItem
Return False
End Function
Private Function IsItemsChecked(ByVal items As List(Of Object)) As Boolean
For Each filterItem As PivotGridFilterItem In items
If filterItem.IsChecked = False Then
Return False
End If
Next filterItem
Return True
End Function
End Class
<%@ Page Title="Home Page" Language="vb" AutoEventWireup="true"
CodeFile="Default.aspx.vb" Inherits="_Default" %>
<%@ Register assembly="DevExpress.Web.ASPxPivotGrid.v13.1, Version=13.1.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" namespace="DevExpress.Web.ASPxPivotGrid" tagprefix="dx" %>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<title>Demo</title>
</head>
<body>
<h2>
Custom filter range sample </h2>
<form id="form1" runat="server">
<div>
<dx:ASPxPivotGrid ID="ASPxPivotGrid1" runat="server">
</dx:ASPxPivotGrid>
</div>
<input runat="server" type="hidden" name="filterRanges" id="filterRanges" value="" />
</form>
</body>
</html>
Imports Microsoft.VisualBasic
Imports System
Imports System.Collections.Generic
Imports System.Web
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Runtime.Serialization
Imports System.Runtime.Serialization.Formatters.Binary
Imports System.IO
Imports System.Data
Imports DevExpress.Web.ASPxPivotGrid
Imports DevExpress.XtraPivotGrid
Partial Public Class _Default
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
ASPxPivotGrid1.DataSource = CreateCustomDataTable()
If (Not IsPostBack) AndAlso (Not IsCallback) Then
Dim fieldQuantity As New PivotGridField("Quantity", PivotArea.DataArea)
Dim fieldProductName As New PivotGridField("ProductName", PivotArea.RowArea)
Dim fieldDate As New PivotGridField("Date", PivotArea.ColumnArea)
fieldDate.GroupInterval = PivotGroupInterval.Date
ASPxPivotGrid1.Fields.AddField(fieldProductName)
ASPxPivotGrid1.Fields.AddField(fieldDate)
ASPxPivotGrid1.Fields.AddField(fieldQuantity)
End If
CType(New CustomFilterRanges(ASPxPivotGrid1, ASPxPivotGrid1.Fields("ProductName")), CustomFilterRanges).AddEvents()
CType(New CustomFilterRanges(ASPxPivotGrid1, ASPxPivotGrid1.Fields("Date")), CustomFilterRanges).AddEvents()
End Sub
Private Function CreateCustomDataTable() As DataTable
Dim customDataTable As New DataTable("Shopping")
customDataTable.Columns.Add("Quantity", GetType(Single))
customDataTable.Columns.Add("Price", GetType(Single))
customDataTable.Columns.Add("ProductName", GetType(String))
customDataTable.Columns.Add("Date", GetType(DateTime))
customDataTable.Rows.Add(5.0, 50.0, Nothing, DateTime.Today.AddYears(-1).AddMonths(-1))
customDataTable.Rows.Add(10.0, 31.0, Nothing, DateTime.Today.AddYears(-1).AddMonths(-1))
customDataTable.Rows.Add(3.0, 30.0, Nothing, DateTime.Today.AddYears(-1).AddMonths(-1))
customDataTable.Rows.Add(3.5, 230.0, "Bananas", DateTime.Today.AddYears(-1).AddMonths(-1))
customDataTable.Rows.Add(5.0, 50.0, "Apples", DateTime.Today.AddDays(-8))
customDataTable.Rows.Add(10.0, 31.0, "Peaches", DateTime.Today.AddDays(-8))
customDataTable.Rows.Add(3.0, 30.0, "Lemons", DateTime.Today.AddDays(-8))
customDataTable.Rows.Add(3.5, 230.0, "Bananas", DateTime.Today.AddDays(-8))
customDataTable.Rows.Add(5.0, 52.0, "Apples", DateTime.Today.AddDays(-7))
customDataTable.Rows.Add(1.0, 33.0, "Peaches", DateTime.Today.AddDays(-7))
customDataTable.Rows.Add(2.0, 32.0, "Lemons", DateTime.Today.AddDays(-7))
customDataTable.Rows.Add(2.3, 250.20, "Bananas", DateTime.Today.AddDays(-7))
customDataTable.Rows.Add(5.0, 50.0, "Apples", DateTime.Today.AddDays(-6))
customDataTable.Rows.Add(10.0, 31.0, "Peaches", DateTime.Today.AddDays(-6))
customDataTable.Rows.Add(3.0, 30.0, "Lemons", DateTime.Today.AddDays(-6))
customDataTable.Rows.Add(3.5, 230.0, "Bananas", DateTime.Today.AddDays(-6))
customDataTable.Rows.Add(5.0, 52.0, "Apples", DateTime.Today.AddDays(-2))
customDataTable.Rows.Add(1.0, 33.0, "Peaches", DateTime.Today.AddDays(-2))
customDataTable.Rows.Add(2.0, 32.0, "Lemons", DateTime.Today.AddDays(-2))
customDataTable.Rows.Add(2.3, 250.20, "Bananas", DateTime.Today.AddDays(-2))
customDataTable.Rows.Add(1.0, 55.0, "Apples", DateTime.Today.AddDays(-1))
customDataTable.Rows.Add(2.0, 38.0, "Peaches", DateTime.Today.AddDays(-1))
customDataTable.Rows.Add(1.0, 36.0, "Lemons", DateTime.Today.AddDays(-1))
customDataTable.Rows.Add(2.0, 55.0, "Apples", DateTime.Today)
customDataTable.Rows.Add(2.0, 39.0, "Peaches", DateTime.Today)
customDataTable.Rows.Add(1.0, 37.0, "Lemons", DateTime.Today)
customDataTable.Rows.Add(3.5, 270.30, "Bananas", DateTime.Today)
customDataTable.Rows.Add(2.0, 55.0, "Apples", DateTime.Today.AddDays(1))
customDataTable.Rows.Add(3.0, 40.5, "Peaches", DateTime.Today.AddDays(1))
customDataTable.Rows.Add(4.2, 290.8, "Bananas", DateTime.Today.AddDays(1))
customDataTable.Rows.Add(10.0, 56.0, "Apples", DateTime.Today.AddMonths(1))
customDataTable.Rows.Add(1.0, 41.0, "Peaches", DateTime.Today.AddMonths(1))
customDataTable.Rows.Add(2.0, 39.0, "Lemons", DateTime.Today.AddMonths(1))
customDataTable.Rows.Add(1.5, 290.30, "Bananas", DateTime.Today.AddMonths(1))
customDataTable.Rows.Add(10.0, 56.0, "Apples", DateTime.Today.AddMonths(1).AddDays(1))
customDataTable.Rows.Add(1.0, 41.0, "Peaches", DateTime.Today.AddMonths(1).AddDays(1))
customDataTable.Rows.Add(2.0, 39.0, "Lemons", DateTime.Today.AddMonths(1).AddDays(1))
customDataTable.Rows.Add(1.5, 290.30, "Bananas", DateTime.Today.AddMonths(1).AddDays(1))
customDataTable.Rows.Add(5.0, 57.2, "Apples", DateTime.Today.AddYears(1))
customDataTable.Rows.Add(3.0, 42.0, "Peaches", DateTime.Today.AddYears(1))
customDataTable.Rows.Add(1.0, 43.0, "Lemons", DateTime.Today.AddYears(1))
customDataTable.Rows.Add(1.2, 295.30, "Bananas", DateTime.Today.AddYears(1))
Return customDataTable
End Function
End Class