We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Select Rows Based on Cell Value within that row

Thread ID:

Created:

Updated:

Platform:

Replies:

121605 Jan 6,2016 10:19 PM UTC Jan 7,2016 12:09 PM UTC WPF 1
loading
Tags: SfDataGrid
Alex Gravely
Asked On January 6, 2016 10:19 PM UTC

I have a datagrid populated with information. I want to create a button that will select all rows that contain a text cell with the phrase "Bulk." How do I accomplish this?

Ayyanar Sasi Kumar Jeyaraj [Syncfusion]
Replied On January 7, 2016 12:09 PM UTC

Hi Alex,

Thanks for contacting Syncfusion support.

You can achieve your requirement by GetPropertyAccessProvider.By using this you can get the value of the record data and the mapping name of the datagrid. When the record data is equal to the given phrase value, the row will be selected.
Please refer the below code snippet
C#

private void datagrid_ItemsSourceChanged(object sender, GridItemsSourceChangedEventArgs e)

        {

            if (datagrid.View != null)

                reflector = datagrid.View.GetPropertyAccessProvider();

            else

                reflector = null;

        }




private void Button_Click(object sender, RoutedEventArgs e)

        {

            var totalRowIndex = datagrid.View.Records.Count;

            var totalColumnIndex = datagrid.Columns.Count; 

            for (int recordIndex = 0; recordIndex < totalRowIndex; recordIndex++)

            {

                for (int columnindex = 0; colindex < totalColumnIndex; columnindex++)

                {

                    var record = this.datagrid.View.Records[recordIndex];

                    var mappingName = datagrid.Columns[columnindex].MappingName;

                    var currentCellValue = reflector.GetValue(record.Data, mappingName);

                    if (currentCellValue.ToString()== "Bulk")

                    {

                        object item = datagrid.View.Records[recordIndex];

                        datagrid.SelectedItems.Add(item);

                    }

                }

            }
        }


Sample Location: http://www.syncfusion.com/downloads/support/forum/121605/ze/WPF1885539734


Please let us know if you have any further assistance.

Regards
Ayyanar

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;