|
Rank: Member Groups: Member
Joined: 9/6/2007 Posts: 29
|
I have a need to add rows to a Grid without using Databinding. However, there doesn't appear to be an easy way to do it. I tried:
Code: C#
foreach (ProjectDetailInfo detail in details)
{
EO.Web.GridItem item = new EO.Web.GridItem();
for (Int32 cellIndex = 0; cellIndex < detail.Columns.Count; cellIndex++)
{
item.Cells[cellIndex].Value = detail.Columns[cellIndex];
}
_ProjectDetailsGrid.Items.Add(item);
}
but the new EO.Web.GridItem(); is undefined How do I do this?
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,193
|
Hi,
You would still do it through data binding. Grid can bind not only from traditional data source, but also from an array of objects or IEnumerable. So in your case you can simply set the Grid's DataSource to "details", and configure each column's DataField to the corresponding property name and then call DataBind.
Thanks
|
|
Rank: Member Groups: Member
Joined: 9/6/2007 Posts: 29
|
Hmm... The problem is that I cannot DataBind, because the Column Property names do not exist. Binding requires:
column.DataField = columnName;
And that columnName needs to be a Property. My item is an array - I manually create the needed columns and want to set each row's cells to the appropriate array item (as shown in the original post).
Why not have the GridItem constructor visible? This solves a plethora of problems
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,193
|
I see. Unfortunately there doesn't seem to be a way to create GridItem directly. GridItem does not have a public constructor so whenever you try to do that you will get compiler error. The only workaround seems to be defining a wrapping class and define corresponding properties on the wrapping class for each column. In the future, we might allow you to specify the DataField as "$1", "$2" to specify array index.
|
|
Rank: Member Groups: Member
Joined: 9/6/2007 Posts: 29
|
Herein lies the reason I have yet to use the grid in any production code. Design decisions were made to hide functionality, rendering the tool all but useless. This is the 5th project I have tried to use find a way to use this grid, and every time it comes up short. Your other tools are quite useful, but this one just isn't ready for real development work.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,193
|
Hi,
We appreciate your candid feedback. :) The Grid has many clear advantages over similar products, while it might require some extra coding to get it work for certain scenarios, such as yours. The extra coding is quite doable, and actually very simple. From our part, we absolutely understand there are always rooms to improve as to usability and it is to certainly towards our goal to make the product as easy to use as possible (That’s why we are thinking about support $1, $2 as property names). From your part, we would also expect you to understand that unlike our other controls, the Grid is very data centric and it almost always requires some data driving/wrapping code, because everybody's data structure is different. This is vastly different than other controls such as Menu, which you cans simply use out of box without any coding.
Thanks
|
|
Rank: Member Groups: Member
Joined: 10/15/2007 Posts: 23
|
I have been running into the same issue as patingamon. I agree that preventing the developer from adding rows manually (in a simple fashion) limits the control big time. It is for that reason that I had to purchase another grid to do the job. With all the advantages your grid has to-date, I would suggest adding/unhiding this sort of functionality to make it even more useful. Plus I would love to keep all of my controls in one family if that were possible!
Just my 2c. David
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,193
|
Totally agree. We are working on that and hopefully it will be supported soon.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,193
|
This feature has been implemented in EO.Web 2008. In this version you can do something like this:
Code: C#
EO.Web.GridItem item = Grid1.CreateItem();
item.Cells[0].Value = "abc";
item.Cells[1].Value = "def";
Grid1.Items.Add(item);
Thanks
|
|