Hello,
Is that possible to use list of arrays as datasource for WebGrid? It could be an array of value types or typed array
For example:
class Person {
int ID { get; set;}
string Name { get; set; }
}
List<object[]> list = new List<object[]>
list.Add( new object[] { 1, new Person() });
and then grid binds columns to array by index and not to property. For example, it would bind 1st column to object[0], 2nd column to object[1].Name and so on.
I compose a grid at runtime and I don't know how many columns I would have. I tried to make new types with System.Reflection but this consumes too many resources.
Thank you.
The XamWebGrid would not bind to this structure. It binds to properties off the individual data object in the collection.
Is there a way to bind XamWebGrid to variable length array?
The Grid expects an IEnumerable of a typed object. A list of Person objects would be bound to, but you would not be able to have a jagged array of objects bound to (with row one having 5 elements, and row two having 8 elements).
No, I didn't mean that one row has 5 elements and second has 8.
For example, I have few objects in database which are going to look like tables on web client. Let's call them views (like in SQL database). One view will have 5 columns and another one will have 10 columns. They're going to be viewed in the same grid but not at the same time. They can be open in different tabs or whatever. But I need a single class which will display them and build a grid at runtime.
That was what I was talking about.
In that case you are probably going to have to use template columns (and custom columns).
A colleague, Steve, has already responded to a post concerning how to do this with a data source that was similar to a statebag
The Grid will not just bind to locations in an array. You would have to set up the columns to this themselves.
http://community.infragistics.com/forums/t/32460.aspx