Skip to main content

Index and Value do not match

Comments

1 comment

  • Dapfor Team

    Hi,

    The problem is that your data doesn't have string identifiers which can be used to display content in cells. I.e. your add data is like object[]. Therefore each value in the object[] can be accessed only by its index. When you reorder or filter columns, the grid can' detect which index should be used to get nested value. Our recomendation is to use objects of custom classes:

    class MyClass
    {
    decimal Name {get; set;}
    decimal Price {get; set;}
    }

    grid.Headers.Add(new Header());
    grid.Headers[0].Add(new Column("Name"));
    grid.Headers[0].Add(new Column("Price"));

    grid.Rows.Add(new MyClass());


    This is more performant, takes less memory, makes the code more clean, and brings separation business level from its presentation.

    Regards,
    Dapfor

    0

Please sign in to leave a comment.

Powered by Zendesk