gridView on transposed data

Posts   
 
    
JayBee
User
Posts: 280
Joined: 28-Dec-2006
# Posted on: 20-Jun-2007 17:32:03   

Hi,

I do not know if this is the correct forum,but....

I have a data structure that look like an n x m matrix (n rows, m columns). From a user-interface perspective it is better to present the data as an m x n matrix. I tried to do this using a DataTable. For display purposes this works fine. However, when I put a row in edit-mode, I am unable to capture the changed values. In the RowUpdating event, the new and the old rows are empty.

I am now considering to set up an ObjectDataSource and implement the getData and update methods for a seperate class representing the rows of the m x n matrix. However, I was wandering if it would be easier to do this using LLBLGen.

Is it possible, or should I go for the ObjectDataSource implementation?

Best regards,

Jan

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39749
Joined: 17-Aug-2003
# Posted on: 20-Jun-2007 22:52:17   

Is one row an entity, or one column an entity? Or is all data 1 entity?

Frans Bouma | Lead developer LLBLGen Pro
JayBee
User
Posts: 280
Joined: 28-Dec-2006
# Posted on: 20-Jun-2007 23:15:30   

Its a matrix where an i,j points is true or false. In the database he number of rows is variable, the columns is variable. For a specific parent the number of rows is fixed, Columns can be added / deleted. i,j points can be changed to true or false.

In the DB for each column there is one record. The positions in the column where an entry is true is modelled as a string (not realy using 3rd normal form, but defining an entity with a lot of key values and just true or false did not seem the correct thing to do). From a user point of view, each column represents something that in the real world looks like a row.

I would prefer to have something like a ASP.NET table control without any binding to database entities. Perhaps I should use a datagrid in stead of a gridview.

Jan

Walaa avatar
Walaa
Support Team
Posts: 14983
Joined: 21-Aug-2005
# Posted on: 21-Jun-2007 10:25:25   

Its a matrix where an i,j points is true or false. In the database he number of rows is variable, the columns is variable. For a specific parent the number of rows is fixed, Columns can be added / deleted. i,j points can be changed to true or false.

In the DB for each column there is one record. The positions in the column where an entry is true is modelled as a string (not realy using 3rd normal form, but defining an entity with a lot of key values and just true or false did not seem the correct thing to do). From a user point of view, each column represents something that in the real world looks like a row.

I would prefer to have something like a ASP.NET table control without any binding to database entities. Perhaps I should use a datagrid in stead of a gridview.

I'm afraid I can't follow the scenario here. Would you please try to elaborate with some data examples and a database structure if possible?

JayBee
User
Posts: 280
Joined: 28-Dec-2006
# Posted on: 21-Jun-2007 19:16:14   

Hi,

I have added a bitmap showing the UI. The user should be able to add a column. In the database each column is a record; from that perspective it would have been better to show one row after another and allowing the user to add rows. It would be difficult to fit on one page. Also the way it currently is presented reflects the real situation better.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39749
Joined: 17-Aug-2003
# Posted on: 25-Jun-2007 19:04:47   

I'll move this to Architecture as it has more to do with design of a db than with direct llblgen pro related material

Frans Bouma | Lead developer LLBLGen Pro
JayBee
User
Posts: 280
Joined: 28-Dec-2006
# Posted on: 25-Jun-2007 20:28:43   

Hi Otis,

It is ok to move it elsewhere. However, I do not think it is a datadesign issue.

When I would have modelled it up to 3rd normal form, it would even be more difficult to present the data the way I want to.

IMHO the structure of data, i.e. a datamodel, does not need to be in line with the presentation of the data.

Jan

JayBee
User
Posts: 280
Joined: 28-Dec-2006
# Posted on: 08-Jul-2007 22:15:13   

I noticed there is also a Databinding category. Perhaps this issue should be moved there?

Jan

Walaa avatar
Walaa
Support Team
Posts: 14983
Joined: 21-Aug-2005
# Posted on: 10-Jul-2007 10:51:39   

I'm sorry but still, I can't follow the description. Still I think my previous request is still valid:

Would you please try to elaborate with some data examples and a database structure if possible?

JayBee
User
Posts: 280
Joined: 28-Dec-2006
# Posted on: 10-Jul-2007 19:41:18   

Walaa,

I have to represent a reinforcement frame for the concrete industry. The reinforcement frame itself is a 3 dimensional space of metal bars of a fixed length hanging in that space (Z-dimension). I want the user to be able to specify the X and Y positions of each bar. I show him a 2-dimensional space in a gridview and enable to change this.

Entity A : Entity C = 1 : n Entity B : Entity C = 1 : m

Entity C represents a point in a 2-dimensional space.

Entity A represents a vertical position. Entity B represents a horizontal position.

The number of possible vertical position is either 3, 4 or 5 and known in advance. The number of possible horizontal positions is 7, 8, 9, ....., 20.

I use a gridview to present the two-dimensional space (see the image I added to a previous post). Each row represents a vertical position. Each column specifies a horizontal position. A cell in the gridview is either true or false indicating that the entity C (the metal bar) exists. A user can add or delete horizontal positions.

Hope this clarifies it.

Jan

Walaa avatar
Walaa
Support Team
Posts: 14983
Joined: 21-Aug-2005
# Posted on: 11-Jul-2007 11:12:04   

Alright, so what you are asking is how to create a new column in a datagrid at runtime, right? (un-related to LLBLGen Pro)

I think you will need to create the Grid dynamically in code, i.e create the columns in code. So when a user wants to add a new column, you should run the grid creation code again which create the columns.

JayBee
User
Posts: 280
Joined: 28-Dec-2006
# Posted on: 11-Jul-2007 13:29:45   

Sure, that's what I allready have and working.

The problem is that when the user changes the content of a row (i.e. selects a position), the new value is not available in the row updating or row updted event. Apparently this info is only available for proper ObjectDataSource instances.

I could create an entity in the database representing a row with 20 fields in it. Each field would represent a position. IMHO I should not create such an entity just to be able to present it to the user and aloow him to edit it.

I think that the structure of presentation layer could be different the structure of the data in the database . These should be independent (Model-View-Controler or Model-View-Presenter paradigm). The GridView seems not to allow this.

The question was if there is a simple solution to this? Or should I create some intermediate entity that does support the insert / update / delete logic also present in an ObjectDataSource.

Jan

JayBee
User
Posts: 280
Joined: 28-Dec-2006
# Posted on: 18-Jul-2007 21:56:54   

Got it working.

foreach (GridViewRow row in this.MyView.DirtyRows) { key = System.Convert.ToInt16(row.Cells[0].Text); positions = new ArrayList(); for (int i = 1; i < row.Cells.Count; i++) { cb = ((CheckBox)row.Cells[i].Controls[0]).Checked; if (cb) { position = System.Convert.ToInt32(this.MyView.HeaderRow.Cells[i].Text); postions.Add(pos); } } myEntity.changePositions(key, positions); }

The marked text did the thing. Perhaps not the way to do it, but at least it workssimple_smile