sqram
sqram

Reputation: 7201

Give Wxwidget Grid rows an ID

I posted this in the mailing list, but the reply I got wasn't too clear, so maybe I'll have better luck here.

I currently have a grid with data in it. I would like to know if there is a way to give each generated row an ID, or at least, associate each row with an object.

It may make it more clear if I clarify what i'm doing. It is described below.

I pull data from an SQL table and display them in the grid. I am allowing for the user to add/delete rows and edit cells.

Say the user is viewing a grid that has 3 rows(which is, in turn, a mysql table with 3 rows). If he is on the last row and presses the down arrow key, a new row is created and he can enter data into it and it will be inserted in the database when he presses enter.

However, I need a way to find out which rows will use "insert" query and which will use "update" query.

So ideally, when the user creates a new row by pressing the down arrow, I would give that row an ID and store it in a list(or, if rows already have IDs, just store it in a list) and when the user finishes entering data in the cells and presses enter, I would check if that row's ID is in the in the list. If it is, i would insert all of that row's cells values into the table, if not, i would update mysql with the values.

Hope I made this clear.

Upvotes: 2

Views: 1069

Answers (2)

Toni Ruža
Toni Ruža

Reputation: 7512

You could make your own GridTableBase that implements this, for a simple example to get you started see my answer to this question.

Upvotes: 2

Alan Haggai Alavi
Alan Haggai Alavi

Reputation: 74272

What I did when I encountered such a case was to create a column for IDs and set its width to 0.

Upvotes: 3

Related Questions