Loop through Column Mappings

2 posts, 0 answers
  1. Jeff Waddell
    Jeff Waddell avatar
    16 posts
    Member since:
    Jul 2004

    Posted 07 May 2011 Link to this post

    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.
  2. Ivan Ivanov
    Admin
    Ivan Ivanov avatar
    1218 posts

    Posted 11 May 2011 Link to this post

    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
Back to Top