X - Can i get unique value from column?

Hi, 
Can I get a list filter for a particular column?
Thanks you!

4 Replies

SS Susmitha Sundar Syncfusion Team May 11, 2020 03:59 PM UTC

Hi GridLock, 

Thank you for using Syncfusion controls. 

We are not clear with your requirement. We suspect that you want to filter the particular column. If so, you can use the FilterPredicates.  


If we have misunderstood your requirement, provide more details about your requirement and get back to us.   
  
Regards,   
Susmitha S   




TG The GridLock May 11, 2020 08:10 PM UTC

Hi Susmitha,
that's it! I searched but could not access it..




SS Susmitha Sundar Syncfusion Team May 12, 2020 07:08 PM UTC

Hi khanh dang, 
 
Thank you for the update. 
 
Currently, we are analyzing the feasibility to achieve your reported scenario. We will validate and update you the details on or before May 14, 2020. We appreciate your patience until then. 
 
Regards, 
Susmitha S 
 



SS Susmitha Sundar Syncfusion Team May 13, 2020 05:56 PM UTC

Hi khanh dang, 
 
Thank you for your patience. 
 
You can get the unique items of particular column values. Please refer the below code, 
 
private void button1_Click(object sender, EventArgs e) 
{ 
    IEnumerable<object>  items = this.sfDataGrid1.View.Records.GetSource(); 
    var column = this.sfDataGrid1.Columns[0]; 
    IEnumerable<RecordValuePair> viewRecords = null; 
    var provider = this.sfDataGrid1.View.GetPropertyAccessProvider(); 
 
    // Gets the distinct record that are in the view for the given column. 
    Invoke((Action)(() => 
    { 
        viewRecords = items.Select((x) => 
        { 
            return new RecordValuePair(provider.GetValue(x, column.MappingName), x); 
        }).Distinct(new RecordValueEqualityComparer<RecordValuePair>()); 
 
    })); 
 
    List<int> uniqueCollection = new List<int>(); 
    foreach(RecordValuePair recordValuePair in viewRecords) 
    { 
        var value = recordValuePair.Value; 
        uniqueCollection.Add(int.Parse(value.ToString())); 
    } 
} 
 
Here, you can get the columns list from uniqueCollection list. 
 
 
Please check the sample and let us know if you need further assistance on this. 
 
Regards, 
Susmitha S 


Loader.
Up arrow icon