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 -> General/Other

 hide areas of a record based on database settings

Print topic Send  topic

Author Message
robn

Posts: 70
Posted: 05/10/2006, 8:38 AM

Hi all

I've been set a task that I'm not sure how to resolve.

Basically what is required is one form with multiple fields, but depending on the users role only certain fields/sections will be displayed.

For example if a user is role one they may only see sections 1,2 and 4 whereas if they are role 2 they may only see section 1 and 2 and so on. I intend the users to acces the form from a list screen or a new record button which will contain the user details (userid). These roles may change over time to the form needs to somehow check against the database to see which sections should be shown based on the users role.

Any help or ideas on how to do this would be greatly appeciated.
i'm developing in ASP and MSSQL2000.

many thanks

Rob
View profile  Send private message
marcwolf


Posts: 361
Posted: 05/10/2006, 7:49 PM

This is a tricky one.

One way (and its insecure but will work) is to wrap certain fields etc with a DIV.

Then in the div put a label.. Mark it as HTML and use this to put Style for displaying and hiding. If the DIV is also given an ID then you can do the hiding and viewing using Javascript.

Visually it looks ok. However unless you have disables the View Source aspect on the browser the user (if they can read HTML) can open the page and see the fields contents.


To actually hide or not send the information upto the browser you might have to look at the Panel control.. But I have not used this as yet.

Hope this helps

Dave
_________________
' Coding Coding Coding
Keep Those Keyboards Coding.
Raw Code!!!!!!!
View profile  Send private message
roeya


Posts: 181
Posted: 05/10/2006, 8:43 PM

Robn Hi,

If you try Panel you will see that all the fields you hide become NULLs
when you press Update. Panel is for display only and it is a known limitation of Panel (maybe they fixed it in the new release ?)

You can overcome this limitation by using custom code in the before build sql event to change the update sql and remove the hidden fields.

Somewhat complicated but possible




_________________
http://www.infoneto.com/
View profile  Send private message
robn

Posts: 70
Posted: 05/11/2006, 3:05 AM

Dave and Roeya many thanks for your response.

I think panels may be the way to go. But I am unsure of how to pass the required parameters through to the record to define if a panel or Div should be displayed or not.

I was wondering if some kind of Before Build Select statement would do it. I already have the session("userid") held, but need to check against the database to see what role the user has then pull back the values for each section that role (e.g. role 1, section1 = 1 section2 = 0, section3 = 1 section4= 0 and so on) before I can set the show/hide setting of each of the panels/div's. This statement i am struggling with and also is this the best way to do it?

many thanks again

Rob
View profile  Send private message
robn

Posts: 70
Posted: 05/15/2006, 3:22 AM

I have found a resolve for the above issue, First of all I created panels for the sections I wished to hide based on the role setting visible to True. Then I placed an hidden field on the form for each of the sections parameters(1/0 show/hide). Then in the before show of each hidden field I placed the following code
tblReport.Section3.Value = CCDLookUp("section3","tblrole inner join dbo.tblUserRole on dbo.tblRole.RID = tblUserRole.RID","userid=" & DBReport.ToSQL(session("userid"),ccsInteger), DBReport)

changing the section for the relevant section. This provided me with a 1 or 0 value (show/hide). Then in order to hide or show the panels based on these results I placed the following code in the before show of each panel.

If tblReport.Section1.Value = 0 Then    
     tblReport.Panel_Section1.Visible = false    
   
End if

The above code worked a treat and I can now manage the forms layout based on a database section.

cheers

Rob
View profile  Send private message
roeya


Posts: 181
Posted: 05/16/2006, 6:55 AM

Rob

Very nice solution - I'll test if it works with Perl.

I think you should enter the dolution to the Tips forum.

_________________
http://www.infoneto.com/
View profile  Send private message
blankenb

Posts: 125
Posted: 05/17/2006, 10:20 AM

Quote roeya:
Robn Hi,

If you try Panel you will see that all the fields you hide become NULLs
when you press Update. Panel is for display only and it is a known limitation of Panel (maybe they fixed it in the new release ?)

You can overcome this limitation by using custom code in the before build sql event to change the update sql and remove the hidden fields.

Somewhat complicated but possible






Would you mind providing some sample code?
View profile  Send private message
roeya


Posts: 181
Posted: 05/18/2006, 1:39 PM

blankenb


robn, provided a solution, and coed example above

I am working on Perl version to check if it works, if needed I'll provide the code here

_________________
http://www.infoneto.com/
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.

Web Database

Join thousands of Web developers who build Web applications with minimal coding.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


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