drew..
04.16.2012
i just realized your side is caching the last page i was on, which is a bit crazy, doubly-so given your choice if highlighting colors is horrible for most color-challenged males. Frankly, my eyes cannot see the highlighted number in the page tool at the bottom.
Why remember the last page i was last on is being remembered on a whole new instance of the browser being brought up..?
Hello,
By default, you cannot completely hide the entire navigation control using security permissions. They work only for individual navigation items if they correspond to business objects.
However, the XAF security model allows you to implement your own custom permission and then handle it as required in a controller. Technically, you can use the SecuritySystem.IsGranted method to check whether a role has a certain permission and then execute the code that will hide the entire navigation control. You can learn more on how to access the navigation control from a controller at http://documentation.devexpress.com/#Xaf/CustomDocument2617
I hope this helps.
Thanks,
Dennis
..is there (i am guessing not) a platform-agnostic approach we can discuss? That link directs to a win-based approach. I would prefer the agnostic but if pressed need a Web answer.
I thought this would be simple. After login, simply run a check for a user's roles. With the proper criterion met, simply grab a reference to the main window template, find the navbar, set its' visible to false. I scoured the SC yesterday but missed anything relevant. I was under time constraints for yet another demo on this particular project.
A bit of history to the request now that i have bit more time: it seems almost impossible to manage a security role to hide all but required BOs, when the main BO has associations in a very complex datamodel. I tried so many permutations but NEVER got just the BO showing i wanted. I wanted to hide all but the one. I ended up with everything showing, sometimes a subset that showed no discernible pattern, and most of the time i saw NO items in the navbar. I just gave up but will explore the new security model to see if i can make it happen.
Just offered this as food for thought.. drew..
Hi Drew,
I am afraid we do not have a platform-agnostic solution. In a Web XAF application, to accomplish your task, you can customize the Default.aspx template as follows:
[C#]public partial class Default : BaseXafPage { protected void Page_Load(object sender, EventArgs e) { ... NTAC.Visible = IsNavigationAllowed(); } private bool IsNavigationAllowed() { if (!SecuritySystem.IsAuthenticated) return false; if (SecuritySystem.CurrentUser is ISecurityUserWithRoles) { foreach (ISecurityRole role in ((ISecurityUserWithRoles)SecuritySystem.CurrentUser).Roles) { if (role.Name == "Administrators") return true; } } return false; } ... }
Thanks,
Michael.
i reduced this down to
return (SecuritySystem.CurrentUserName=="admin")?true:false;
as i think the original was geared to the new security system, which i am not yet using.
As well, can you advise exactly which name is required to hide the entire navbar, including the splitter? It seems (i think), based on css styling names, that i have to hide "MT" but this is standard html and not asp-based so i am not able to use MT.Visible= .. etc. thank you kind folks.
Hi Drew,
If you mean the pane with the Diagnostic and Tools action containers on the left side of the page, you can hide it along with the splitter by setting the isLeftPanelVisible variable in the CurrentRequestWindow_PagePreRender method to "false" (in Default.aspx). If you are using a custom template, the code may vary.
Thanks,
Michael.
ok, clearly i am not an asp.net guru, that is why i use XAF.. can i simply have clear explicit instructions on how to hide the entire navigation area? I would like to do it directly in page_load as the other methods in pre-renders that i found in B222054 allow the navbar to show for a brief period, which is not correct. I can simply grab a true/false from the security check, this is not an issue.
At issue is the labyrinth that is Default & DefaultVertical. To repeat: i would like an easy way to remove ALL evidence of the navigation system, including the splitter bar, completely, for non-admin users. The nav logic should also allow for the fact that is NO nav items are showing then the splitter should also go away, this is only logical.
We can do soooo much with xaf, why is it that these seeming simple tasks are so time-consuming unless we are already gifted in the low-level coding arena? ;) thanks kindly, drew..
Hi Drew,
Your requirements are quite unusual. That's why this scenario is not supported out-of-the-box. To hide the navigation pane in the DefaultVertical.aspx template, modify the page markup by adding the runat="server" attribute to the MRC table and add the following code to the Page_Load method:
[C#]bool navBarVisible = ... MRC.Rows[0].Cells[0].Visible = navBarVisible; MRC.Rows[0].Cells[1].Visible = navBarVisible;
Additionally, modify the OnLoadCore method in the TemplateScripts.js file:
[JScript]function OnLoadCore(panelId, separatorCellId, separtorImageId, display, collapseLeft) { tableCellDefaultDisplay = isIE7 ? "block" : "table-cell"; var LPcell = document.getElementById(panelId); var separatorCell = document.getElementById(separatorCellId); if (LPcell == null || separatorCell == null) return; // <--- NEW LINE LPcell.style.display = display ? tableCellDefaultDisplay : 'none'; separatorCell.style.display = LPcell.style.display; var leftPanelDisplay = _aspxGetCookie(panelId + postfix); if (leftPanelDisplay && separatorCell.style.display != 'none') { LPcell.style.display = leftPanelDisplay; } UpdateSeparatorsImages(separtorImageId, collapseLeft, leftPanelDisplay); AdjustSize(); DXattachEventToElement(window, "resize", AdjustSize); }
Thanks,
Michael.
THANK YOU Michael.. Now *that* was a thing of beauty. This will now make a proof-of-concept app so much better. There are often times when we have roles that are very limited that have NO rights to see more than one screen and this is perfect. I see a combination of a switchboard and a navbar-hiding sequence where certain roles go to certain screens. This is LOVELY. thank you. And thank you for your patience with my persistence.
drew..
Sorry to beat a dead horse here, but.. Somehow this has caused the entire splitter, *except* the button to close or move the splitter itself, to disappear. It is empty except the button. I have text diff'd my DefaultVertical.aspx file and there is nothing to account for this. I even commented out the additional line to the js template and found there to be NO change on the actions of the act this entire issue was focused on.
I reset my browser, emptied the cache, everything, no change. This has been happening since the change..
Any thoughts?
Hi Drew,
Thank you for the report. It seems that ASP.NET does not support code blocks within server-based markup elements (see http://stackoverflow.com/questions/4864138/code-blocks-are-not-supported-in-this-context-in-asp-net-control). So, the style we applied to a table cell in our template is not properly set. To workaround this limitation, add the following method:
[C#]protected void Page_PreInit(object sender, EventArgs e) { MRC.Rows[0].Cells[1].Attributes["class"] = "dxsplVSeparator_" + Theme + " dxsplPane_" + Theme; }
Thanks,
Michael.
Is your intention to post an answer to your own question?
- If so, then proceed.
- If you simply wanted to post additional information, ask for further clarification, or to just say "Thanks!", please click Leave a Comment.
- If you wish to edit your original question, please use the Edit button in the Toolbox at the top right corner of that entry.
Facebook
Twitter
Google+