R2i DotNetNuke® Forum

R2i wants you to have the opportunity to ask questions, post reviews, help others or just rant and rave about DotNetNuke® or any of the R2i Modules and Skins. Our team spends hour upon hour, day after day, working on custom DotNetNuke® modules and services; please feel free to ask us anything.
 
How to pass the values of a number of List Item Detail row textboxes to an Action?
Last Post 01 Jan 1900 05:00 AM by . 6 Replies.
Printer Friendly
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages Informative
lnevilleUser is Offline
New Member
New Member
Posts:67

--
27 Feb 2008 06:03 PM  
I want to design a form that displays a number of records from a database and lets the user edit the value in one particular field. However, instead of the usual model of requiring the user to click an "edit" link in the row they want to edit, which then leads to a "record edit" form, I want the values to be editable directly in the table (i.e. the table contains INPUT boxes). Then a single Save button below the table can be clicked to save all the values.

Is this possible (easily) and how?
pauldesUser is Offline
Veteran Member
Veteran Member
Posts:1392

--
27 Feb 2008 08:33 PM  
I know there's an example in these forums somewhere.... but anyway here is the concept as best as I've been able to figure this out

So, say your query in your module is to show all rows in a table and it returns 10 rows
Select name, recordid from employees order by recordid

Then in your Detail section, add the appropriate List Group for the Header/Footer of the table that will display the results, and put a
<a href="lxFetch([*moduleid],0,'SAVE=1');>Save List</a> in your footer or wherever.

Then in you List Detail, format each row like this
<tr><td><input type=text name="frmname[recordid]" id="frmname[recordid]" value="[name]"/></td></tr>
This creates a uniquely named form element for every row containing the name field.

So now your actions would be:
If '[SAVE,Querystring]'='1'
#Execute[GetEmployees]Select * from employees order by recordid
##Execute[DoUpdate] Update employees set name='[frmname[recordid,GetEmployees]]' where recordid = [recordid,GetEmployees]

What this second execute does is find the unique form element that holds the intended value for the record to be updated based on the current record the 1st execute is at in the data set. The second execute is indented under the 1st execute and as a result will execute for each record found in the 1st execute, in this case 10 times.

That should work...there may be a more elegant way.
ListX....makes you look brilliant, even though you're not.
robert_chumleyUser is Offline
Advanced Member
Advanced Member
Posts:592

--
27 Feb 2008 09:36 PM  
I believe Paul is onto something here. You certainly will have to be careful about the way you display and temporarily save this information. Have you looked into Google Gears? I integrated Google Gears in an application I built as a demo recently. This seems to be what you may be looking for. Gears is a database that you can tap directly into and execute against using simple TSQL. It is a little bit of work to get setup, but in the end it holds lots of possibilities for what you are trying to do.

The good part about it is that if you have many edits to do on the screen, and during that time your session times out, power goes out, or anything, then you still have the results saved. When they come back you can have a "sync" button that syncs up their data with what is in the database. Pretty cool actually, but is a little tricky when dealing with DNN. Basically you have to design a really simple skin to hold the multiple edit form. Let me know what you think.
Thanks,
Robert Chumley<br>r2integrated (formally bi4ce)
lnevilleUser is Offline
New Member
New Member
Posts:67

--
27 Feb 2008 11:24 PM  
Thanks very much. I'll try Paul's tip first. I had not heard of Google Gears before today - very interesting but probably not suitable as I am looking for a "traditional" web based solution. Looks like Google Gears requires an app to be installed on the client in order to work.

Out of interest, what does the * in lxFetch([*moduleid],0,'SAVE=1') achieve?
pauldesUser is Offline
Veteran Member
Veteran Member
Posts:1392

--
28 Feb 2008 02:31 PM  
it's just another way of saying [ModuleId,System] . It works for any system variable [*Tabid] etc....

Also, I have a typo or the forum stripped it out. The set in the update should = '[frmname[recordid,GetEmployees], Form ]'

Robert, do you have a sample of how you implemented Gears? Would love to look at it.
ListX....makes you look brilliant, even though you're not.
lnevilleUser is Offline
New Member
New Member
Posts:67

--
14 Apr 2008 01:57 PM  
I used Paul's technique successfully to loop through the records in the form and update them all. There is one thing that doesn't work quite right though.

After the Save button is clicked, the module refreshes and the field values go back to their state before the user modified them. I think that what is happening is that the form is being re-rendered by running the module's main Query BEFORE the actions run and make all the updates to the data (in fact I can see using SQL Profiler that the Select Query for the module runs first, then the Select for the Save action, then each of the Updates). The changes are saved, its just that you have to reload the page to see them.

I have 2 actions (delete, add and save) and each are set up in exactly the same way. I don't understand why for the Delete and Add the action completes and then the module is reloaded, but for the Save it is the other way around.

Here are the actions:

0. If '[Action,QueryString]' = 'Delete'
1. -- Execute Query[Delete]: DELETE FROM Products WHERE ProductNumber=@ProductNumber

2. If '[Action,QueryString]' = 'Add'
3. -- Execute Query[Insert]: insert Products values('[frmProductNumber_Add,Form]', '[frmExclusive_Add,Form]')

4. If '[Action,Querystring]'='Save'
5. -- Execute Query[GetProducts]: select ProductNumber from Products order by ProductNumber

6. ---- Execute Query[DoUpdate]: Update Products set ProductNumber = '[frmProductNumber_[ProductNumber,GetProducts],Form]', Exclusive = '[frmExclusive_[ProductNumber,GetProducts],Form]' where ProductNumber = '[ProductNumber,GetProducts]'

Here is the links that fires the Add action. THe others are in exactly the same format, it is just the 'Action=.....' that is different.

href='#' onclick="lxFetch([ModuleID,System],CURRENTPAGE[ModuleID,System],'Action=Add&ProductNumber=[frmProductNumber_Add,Form]&Exclusive=[frmExclusive_Add,Form]');return false;"

robert_chumleyUser is Offline
Advanced Member
Advanced Member
Posts:592

--
14 Apr 2008 09:59 PM  
There may be several problems here. You cannot pass values back to your save routine using

lxFetch([ModuleID,System],CURRENTPAGE[ModuleID,System],'Action=Add&ProductNumber=[frmProductNumber_Add,Form]&Exclusive=[frmExclusive_Add,Form]');

This information is only available on the client side. You can send the values back, but you do not have to explicitly pass them back in the lxFetch. Then, use the [value,Form] to retain the values when you show the form for the second time. Typically you would use that on the value attribute.
thanks,
Robert Chumley<br>r2integrated (formally bi4ce)
You are not authorized to post a reply.

Active Forums 4.1
 

New York, NY • Baltimore, MD • Vienna, VA • St. Louis, MO • Seatle, WA • 410.327.0007 • info@R2Integrated.com

Bookmark & Share Bookmark and Share