Hi,
I am trying to do filtering in xamgrid. but not able to find out how to filter xamgrid.
Is anyone know how to do the filtering functionality in xamGrid?
Any answer will be appreciated...
IMO I could never understand why filtering was not integrated into the original grid. What is the first thing (maybe after sorting) one does with the grid?
Anyway I haven't figured out the 9.2 filter yet and there doesn't seem to be much call for it on the support forums, but I've worked out my simple filter design which works consistently regardless of what Infragistics has or doesn't have. When in question always go back to WPF.
The real trick to this whole grid display thing is to be at the root of your data. The I Grid is not smart enough to drill down into your data. What you see is what you give it. If the shoe fits, wear it.
I like using linq query or simply the entity class to bind filtered data to the view. When you choose to do this is a function of whether you want it behind a button an event or whatever.
Simply filter and display. No rocket science here.
Below I am filtering on a comboBox (Because I want to filter on a collapsed column which doesn't work on this grid. When Infragistics collapses a column, it's as if it doesn't exist). I use a combination of linq and just Lists. Lists are friendlier to displaying data than are compound entities.
private void cmdSelectArea_SelectionChanged(object sender, SelectionChangedEventArgs e) { try {
FilterUnits = SpinningReserveService.unitCache.TryGetByKey(ASClientCommands.CurrentCaseNumber); List<ASEngine.BusinessObjects.Entities.UnitDetail> SourceUnitList = new List<ASEngine.BusinessObjects.Entities.UnitDetail>();
if (FilterUnits == null) return;
// Return the view to visible status on the first click.
if (this.cmdSelectArea.SelectedItem.ToString() == "SOUTH-S") { string querySeach = this.cmdSelectArea.SelectedItem.ToString(); // Try to filter view on the current selection this.AreaUnitDetails.DataSource = null; this.AreaUnitDetails.DataSource = (from r in FilterUnits where r.Area == querySeach select new { UnitID = r.UnitID, r.Area, r.AreaName, r.CaseID, r.CompanyShortName, r.CondenseEnergyUsage, r.CurregMW, r.CurregSelfMW, r.CurSpinTier2MW, r.CurSpinTier2SelfMW, r.RawRegAssignDelta, r.RawTier2Diff, r.RegAssignDelta, r.RegAssignDeltaFlag, r.RegDeselected, r.RegMW, r.RegRankPrice, r.RegSelfMW, r.ReserveZoneShortName, r.SpinMax, r.SpinRankPrice, r.SpinTier1MW, r.SpinTier2MW, r.SpinTier2OfferMW, r.SpinTier2SelfMW, r.StudyModeID, r.Tier1Deselected,r.Tier2Deselected, r.Tier2Diff, r.UnitLongName,r.UnitType }).ToList(); } else if (this.cmdSelectArea.SelectedItem.ToString() == "All Areas") { // Do not filter view this.AreaUnitDetails.DataSource = null; this.AreaUnitDetails.DataSource = (from r in FilterUnits select new { UnitID = r.UnitID, r.Area, r.AreaName, r.CaseID, r.CompanyShortName, r.CondenseEnergyUsage, r.CurregMW, r.CurregSelfMW, r.CurSpinTier2MW, r.CurSpinTier2SelfMW, r.RawRegAssignDelta, r.RawTier2Diff, r.RegAssignDelta, r.RegAssignDeltaFlag, r.RegDeselected, r.RegMW, r.RegRankPrice, r.RegSelfMW, r.ReserveZoneShortName, r.SpinMax, r.SpinRankPrice, r.SpinTier1MW, r.SpinTier2MW, r.SpinTier2OfferMW, r.SpinTier2SelfMW, r.StudyModeID, r.Tier1Deselected, r.Tier2Deselected, r.Tier2Diff, r.UnitLongName, r.UnitType }); } else { string querySeach = this.cmdSelectArea.SelectedItem.ToString(); string querySearchAux = "RTO-R|RFC-SR"; string strArea = null; // Try to filter view on the current selection this.AreaUnitDetails.DataSource = null;
foreach (ASEngine.BusinessObjects.Entities.UnitDetail ud in FilterUnits) { strArea = ud.Area.ToString(); if ((strArea == querySeach) || (strArea == querySearchAux)) { SourceUnitList.Add(ud); } }
this.AreaUnitDetails.DataSource = SourceUnitList; }
} catch (Exception ex) { Logger.LogException(LogSourceType.ClientApplication, ex); } } }
XamDataGrid doesn't currently have any bulit-in filtering capabilities. Filtering the data source itself is the closest workaround, using whatever UI you choose to set up.
If you're interested in filtering capabilities being added to a future release of xamDataGrid, you can submit a feature request here. Feature requests are one of the tools we use to prioritize what functionality we add to new releases.
I don't think it will be anything easy. I'm not sure what Ultragrid looks like but I think you'd be able to do something similar. It would require creating your own styles for the column headers though, maybe targeting LabelPresenter or something, and setting triggers or event handlers.
yes that's right...
but i want to do something like Ultragrid where user can specift there own custom query for sorting or filtering...
In ultragrid then have provided the feature callled rowfilter which adds the filter image in clicked column header...
is there something in xamgrid so that i can invoke customUI when i click on column..
Alternatively, you can filter your datacontext using ICollectionView and assign that filtered view to the grid's ItemSource.