This is a migrated thread and some comments may be shown as answers.

Loop through Column Mappings

1 Answer 10 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Jeff Waddell
Top achievements
Rank 1
Jeff Waddell asked on 07 May 2011, 10:33 PM
Can anyone tell me how to loop through the column mappings at runtime?  I want to compare the property / column values of two objects by looping through and comparing only the properties that are mapped.

1 Answer, 1 is accepted

Sort by
0
Ivan Ivanov
Telerik team
answered on 11 May 2011, 04:53 PM
Hello Jeff Waddell,

You may try this approach and inform us if it meets your requirements:
public bool CompareItems (object item1, object item2, int columnIndex)
{
    var value1 = (clubsGrid.ItemContainerGenerator.ContainerFromItem(item1) as GridViewRow).ChildrenOfType<GridViewCell>().Where(c => c.Column == clubsGrid.Columns[columnIndex]).First().Value;
    var value2 = (clubsGrid.ItemContainerGenerator.ContainerFromItem(item2) as GridViewRow).ChildrenOfType<GridViewCell>().Where(c => c.Column == clubsGrid.Columns[columnIndex]).First().Value;
    if (value1 == value2)
        return true;
    return false;
}


Greetings,
Ivan Ivanov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
General Discussions
Asked by
Jeff Waddell
Top achievements
Rank 1
Answers by
Ivan Ivanov
Telerik team
Share this question
or