Welcome Guest Search | Active Topics | Sign In | Register

Manually adding rows (items) to a Grid Options
patingamon
Posted: Wednesday, February 27, 2008 9:24:57 AM
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?
eo_support
Posted: Wednesday, February 27, 2008 9:43:58 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,097
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
patingamon
Posted: Wednesday, February 27, 2008 9:54:55 AM
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
eo_support
Posted: Wednesday, February 27, 2008 10:02:09 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,097
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.
patingamon
Posted: Wednesday, February 27, 2008 10:07:10 AM
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.
eo_support
Posted: Wednesday, February 27, 2008 10:19:00 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,097
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
dmacchia
Posted: Monday, April 28, 2008 10:38:03 PM
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
eo_support
Posted: Tuesday, April 29, 2008 6:04:21 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,097
Totally agree. We are working on that and hopefully it will be supported soon.
eo_support
Posted: Sunday, July 20, 2008 9:15:32 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,097
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


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.