123456789101112131415161718192021222324252627282930313233343536373839 |
- using System;
- using System.Windows.Controls;
- using Comal.Classes;
- using InABox.Core;
- using InABox.DynamicGrid;
- namespace PRSDesktop
- {
- public class ContactGrid : DynamicDataGrid<Contact>
- {
- private bool bShowAll;
- public ContactGrid()
- {
- Options.AddRange(
- DynamicGridOption.RecordCount,
- DynamicGridOption.FilterRows,
- DynamicGridOption.SelectColumns
- );
- AddButton("Show All", null, ToggleFavourites);
- }
- private bool ToggleFavourites(Button sender, CoreRow[] rows)
- {
- bShowAll = !bShowAll;
- UpdateButton(sender, null, bShowAll ? "Favourites" : "Show All");
- return true;
- }
- protected override void Reload(Filters<Contact> criteria, Columns<Contact> columns, ref SortOrder<Contact> sort,
- Action<CoreTable, Exception> action)
- {
- if (!bShowAll)
- criteria.Add(new Filter<Contact>(x => x.Favourite).IsEqualTo(true));
- base.Reload(criteria, columns, ref sort, action);
- }
- }
- }
|