CodeCharge Studio
search Register Login  

Web Reports

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> PHP

 variable number of editable grid entries

Print topic Send  topic

Author Message
kirchaj

Posts: 215
Posted: 01/07/2015, 2:13 PM

Ok. I am not even sure how to get my head around this one but there has to be a way.

We have a variable number of Standards associated with each Assignment.

Assignment1 ST1, ST5
Assignment2 ST1, ST3, ST5, ST7........

I need an entry form that will go out, read the number Standards, and generate an editable grid (only option I can think of) so the Faculty can add scores (1 2 3 4) for each Standard.

Assignment1
ST1 1 2 3 4
ST5 1 2 3 4

Assignment2
ST1 1 2 3 4
.
.
ST7 1 2 3 4

I am always up for a challenge but this one has me stumped. Any ideas?

Thanks so much.
TK
View profile  Send private message
eratech


Posts: 513
Posted: 01/07/2015, 9:31 PM

TK,

Interesting - you have nerd sniped me ( http://xkcd.com/356/ )

Here's my first go at it.

If you have the structure with a literal delimited list of Standards:
"Assignment1" and "ST1,ST3"
"Assignment2" and "ST1,ST3,ST5,ST7"

You can convert that to a recordset (rows) using something like:
http://stackoverflow.com/questions/18304857/split-delim...value-into-rows
or
http://stackoverflow.com/questions/17942508/sql-split-v...o-multiple-rows

Then you can make some SQL as the Datasource for the editable grid and simply return the Assignment and Standard Rows (you can add some dummy columns for Results if you want: '' as Result1, '' as Result2 etc)

Editable Grid:
Assignment Standard Result 1 Result 2 Result 3 Result 4
1 1
1 3

Remember that you can use Custom Insert to do whatever you want with each row, instead of it needed to go back into the source table (which doesn't really exist at this stage).

I would suggest INSERT into a [Results] table with schema similar to the above Editable Grid (so it can have 1, 2, 5, 20... results for each Assignment and the Assignment and Standard is the combination key for the table)

To Edit the Results table is then just a standard Editable Grid with Table datasource and no Custom Update.

Does that help?

Cheers

Eric
_________________
CCS 3/4/5 ASP Classic, VB.NET, PHP
Melbourne, Victoria, Australia
View profile  Send private message
cvboucher

Posts: 191
Posted: 01/08/2015, 10:42 AM

What if you inner joined the Assignment and Standards tables and left outer joined the Scores table. Then in the Custom Update you either inserted or updated the row depending on if it already existed or not. I know this can be done with a stored procedure. I think it could be done with SQL if your database has a MERGE command (I know SQL Server and Oracle does. It looks like MySql has an ON DUPLICATE KEY UPDATE command).

You would never have Inserts so set the empty rows to 0. Deletes could be done with a custom table delete on the Scores table.

Craig
View profile  Send private message
eratech


Posts: 513
Posted: 01/08/2015, 7:19 PM

Craig - yes, that would work too. Both have a Edit Grid based on a 'virtual recordset' (i.e.: not working straight on a table, but getting the fields you want to display) and then handle the Insert and Update differently as needed.

I wasn't sure if there was a 'Standard flag' or a table, but the idea is the same - I've used the Stored Proc method myself for another project when they usually are inserting a new comment, but might be updating a previous year's comment, and the SP is a nifty way of handling that.

I also work with MySQL And MSSQL so I try not to use some of the DB specific functions as it makes my code less portable - but obviously also loses some of the usefulness.
Eric


_________________
CCS 3/4/5 ASP Classic, VB.NET, PHP
Melbourne, Victoria, Australia
View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

Internet Database

Visually create Web enabled database applications in minutes.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.