I am using XamDataGrid 9.1 with record filter. I am looking for a property that given me the count of no. of records available in the grid at any point. XamDataGrid.Records.Count gives me total no of records. This always gives me the total no. of records.
What I am looking for is a property that gives the correct count of visible records when filters are applied.
This is correct, RecordsInViewChanged doesn't fire if filter record count is 0. :-( M facing this issue too! Any soulution for this? which event fires after filter is applied on XamDataGried?
Hello,
I have been looking into this issue and think have found a pretty easy way to get what you need:
xamDataGrid1.RecordManager.GetFilteredInDataRecords().Count<DataRecord>();
Hope this is what you were looking for. Let me know if I can assist you further on the matter
Sincerely,
Petar Monov
Developer Support Engineer
Infragistics Bulgaria
www.infragistics.com/support
Actually it's a pretty serious API bug by Infragistics.
RecordManager.FilteredInDataItems is ICollectionView (IEnumerable) according to the API, but in runtime it's got different type (FilteredDataItemsCollection) which is IList (!) and it's an internal class, so it can't be used in user's code.
Therefore users have to call those methods, get collections and iterate/cast to get the count! What a performance issue.
And also there is no property changed event exposed. So it's hard to track the number of filtered rows.
I suggest Infgaristics fixing it asap.
I've tried accessing this property in code, using the latest version (10.2.20102.2045).
FilteredInDataItems inherits from ICollectionView, but that does not have a count property. The FilteredDataItemsCollection does have a count property, but the collection is "Friend" so I can't cast to it. Am I missing something obvious?
I subsequently tried using RecordManager.GetFilteredInDataRecords.Count, that does return a value. However, this appears to return the number of DataRecords whose Visibliity is not 'Collapsed', not those whose IsFilteredOut property is false (which is what I'm after). I am setting some DataRecords visibilities to collapsed via a 'find' mechanism I've created, but I still want these records included in the 'filtered-in' count as these records do still satisfy the filter, they just happen to be not visible. [as also mentioned, this method has the downside of creating a new list]
I therefore created my own function that iterates all the records, counting those whose IsFilteredOut property is nothing (the case when no filters are applied) or false... but is there an easier way?
Dim count As Integer = 0
' Loop through the list of records.
For Each rec As Record In records
Select Case TypeName(rec)
' For GroupByRecords, do a recursive call for the child records.
count += Me.CountFilteredRecords(DirectCast(rec, GroupByRecord).ChildRecords)
Dim record As DataRecord = DirectCast(rec, DataRecord)
count += 1
Throw New NotImplementedException("Record type not implemented.")
Next rec
Return count
End Function
You can probably check the RecordFilterChanged as this one will fire.