Is it possible to stop the propagation of a taghelpers in one of the taghelpers linked to that tag? - asp.net-core-mvc

I would like to stop the propagation of any taghelpers linked to a tag. I have a attribute based taghelper that I use to check whether the user can see or use a tag, and based on that I would like to stop any further processing to happen.
output.SuppressOutput();
does not work in this regard.
Some more detail.
I have a grid that has rows and actions per row ( actually there are other types of actions, ie on the grid etc) the rendering of the actions happens using a grid renderer.
The actions are added to a context that is provided to the grid via the items property.
I have another taghelper that can be placed on any tag element which determines whether the user has rights to see the element or whether it is disabled. This taghelper is first in the hierarchy.
Now since the actual action taghelper doesn't render itself, the grid renders it, I can't suppress the output of the action, as it continues to the next taghelper in the hierarchy and adds it to the context.
I would like it stop executing the taghelper hierarchy and not add it to the context, without being able to stop the execution I have to now pass whether the action should be displayed or disabled along in the context and update all my various renderers code to handle this. Stopping the exectution is much simpler and touches a lot less code.

Related

extjs Save component view state before removing it from parent component

Let me explain the my scenario. I am using ExtJS5. I have got a view component (let us name is viewOne) contain two combo boxes, button search and some action button, on click of search button the grid is populated. This viewOne is in a parent view component (viewParent). I need to load a second view (viewTwo) on selecting some grid row and clicking some action button a new view is loaded (viewTwo) in the parentView. When I come back from viewTwo to viewOne I need old values of combo boxes to re perform the search.
Currently I am storing the values of combo boxes in a store and set then when the after view render and call search. We have discarded card layout for this implementation.
I wanted to know how this can be done via Ext.state , I cannot find any example on the same that is close solution to my problem. Any other way of doing this ?
State seems reasonable for that. First of all you must set StateProvider (by calling Ext.state.Manager.setProvider) to instance of class which extends Ext.state.Provider.
Then state should work for you. Only thing that you must remember is to set stateful property to true and set stateId of the component.
Usually you don't need to save state by yourself. All built-in stateful components have defined state events. When such state event occur (eg. expand on panel) then state is saved automatically. You can customize state events by calling addStateEvents in initComponent.
To provide custom component state you should override applyState and getState methods. When you combine it with addStateEvents you have all what you need.
Example: http://jsfiddle.net/48jw81da/16/

Setting the parent elements of Kendo UI content

I'm using some KendoUI web widgets such as DropDownList, which create 'div' elements that are being added to the bottom of the Body. is there a way to configure those to be added as children of one specific div, instead of being direct children of 'body'?
Some widgets have an appendTo configuration option, e.g. kendoWindow, but most don't. kendo.ui.Popup (which is used by widgets like kendoDropDownList and kendoComboBox) appears to be using that configuration option, so it might be relatively easy to make some changes to achieve what you're after.
In response to your follow-up question: there is no document for kendo.ui.Popup because it's not intended to be used independently - it's just a reusable component for the framework itself.
If you're concerned about having to clean up the DOM elements created by a widget, you can achieve that by using the widget's destroy method.

Updating Controls from Multiple Pages on Windows Phone

All, I am new to Windows 7 Phone. My situation is that I have a main page which contains a ScrollViewer which in turn houses a StackPanel. I want to populate this StackPanel with multiple sub-StackPanels (at runtime) which are to hold an Image Thumb nail a hyperlink and some basic information about the image.
This is all good when I do this from the main page, but I want to know how to update this control (which is on the main page), but from any page other than the main page. I would like to know what is considered best practice for updating a page's control (like that outlined above) from another page.
Obviously there are a number of ways to pass data between pages
PhoneApplicationService.Current.State["yourparam"] = param
NavigationService.Navigate(new Uri("/view/Page.xaml", UriKind.Relative));
then in other page simply
var k = PhoneApplicationService.Current.State["yourparam"];
and many others. But what is best practice for updating a generic control from a different page?
Note: There are many question about data access and passing between pages.
Passing data from page to page
How to pass the image value in one xaml page to another xaml page in windows phone 7?
Passing image from one page to another windows phone 7
and more. This is not what I am asking.
If I understand your question correctly, you are trying to update a control which is on for example MainPage.xaml from another page for example Page2.xaml.
As far as I know there is no way to reach a pages controls from another page, and that seems unnecessary for the cases that I can think of.
The method used to achieve what you are trying is usually done by triggering an action (like the press of a button ) and passing a parameter to the page you are trying to update the control. And on that page's onnavigatedto event (or viewmodel constructor if you are using the MVVM pattern), update your control based on the passed parameter.
If your update is based on data then the best practice is to bind an observable collection or an object that extends the INotifyPropertyChanged (basically any object that can signal that one of their property changed to the ui) and change the data based on the parameter that is passed.
If these two pages somehow are visible at the same time and there is no navigation needed between them( like a popup or sliding menu kind of ui) then you can make the page that you are showing in the popup a usercontrol, and reach to the parent's controls by this.Parent.
I can be more helpful if you give more specifics about your app's flow.
The MVVM pattern would be a good way to go. Saying MVVM is too complicated for small teams isn't exactly accurate - the purpose of MVVM is to decouple Silverlight or WPF code. Using the codebehind of a Silverlight page to directly access data creates coupling in your code and accrues technical debt. Whether you're one developer or 100, if your UI is coupled with your data classes, if you have to change your data classes, you will have to make changes to every UI element that uses those classes. This takes longer and makes your application more difficult to change.
MVVM makes it so your UI (the View) doesn't know anything about the data (your Model). The ViewModel is the code in between that the UI can bind to, and which manages events in the UI that need to be persisted to the Model, and also changes in the Model that need to be represented in the View. For this reason, it handles events, and that's what it sounds like you need in your code - an event that can exist off of the codebehind, that can update the Views bound to it when the data changes. If you have two pages, then an event on one of the pages will be sent to the ViewModel, which will make a change to the Model (data) if necessary, and pass it back to the ViewModel. The ViewModel would then update any of the UI elements (Views) bound to that piece of data.
There's a REALLY good demonstration of how to implement the MVVM design pattern here
. The guy goes through and takes a typical WPF application (just like Silverlight), where the UI codebehind implements event handlers that directly access data, and refactors it using the MVVM pattern.

PRISM: Passing object/events from parent to child View/VM with PopupRegions

We are working with an application that uses prism and MVVM for healthcare tracking operations.
Within this application, we have registered views in primary regions, and scenarios in which clicking on a cell in a grid (in this case a xamdatagrid - Infragistics) will launch another region via the prism region popup behaviors constructs.
So, when we click on the cell, a cellactivation operation in the code behind for that view is called which then calls a method in the view model to .RequestNavigate to the view that is registered for the 'secondary' popup region (thus launching what appears to be a dialog over the existing application).
I am attempting to pass an object from the parent view (the values of the record in the grid) to the child view that is launched in the popup, and have found that none of the expected operations is working.
I have a mediator object that we are using to pass information back from children to parents, but this does not work the other direction because the publish/notify operations for the mediator require the child view to 'already' be instantiated before the parent publishes to pass that information.
I'm finding that the event aggregator structures built into the Prism.Events classes don't appear to be working either (I'm assuming because of the same publish/subscribe issues). I can publish an event through the event aggregator from the parent view and subscribe in the child view, but I have to launch the child view 'twice' in order to get the event tied to the event aggregator operation to actually fire.
I understand this is rather vague (minus the code), but I'm looking more for a start point, or anyone that's run into the same kinds of issues. The bullet point scenario is as follows:
Parent view already instantiated in existing region.
Clicking on cell in parent view instantiates (navigates to) child view in popup region.
Same click operation needs to pass an object from the parent view to the child view so that the child view can filter its own data based on that object.
Operations are constructed using Prism/MVVM.
Any help, suggestions, pointers, ideas would be awesome.
We had the same scenario and ended up with creating a UiService that are injected to our ViewModels. Our ViewModel base class has a SetModel method which the UiService calls when navigating, for sending parameters to the destination view.
By example:
Clicking a button in the existing View.
Source ViewModel calls UiService ShowView(data).
UiService calls RequestNavigate for the requested view.
UiService calls SetModel on the destination ViewModel (by accessing the DataContext of the requested view) to pass in the data from the source ViewModel.
Depending what you want to pass it can be pretty simple with INavigationAware
Sounds like you want to pass something like query string - parameters, etc. Code to open window will be like this:
var query = new UriQuery
{
{ "MailItemKey", this.SelectedMailItem.MailItemKey.ToString(CultureInfo.InvariantCulture) }
};
RegionManager.RequestNavigate(RegionNames.Popup, typeof(MailItemView).Name + query.ToString());
And inside MailItemViewModel which is our popup's VM code is like this:
public override void OnNavigatedTo(NavigationContext navigationContext)
{
var mailItemKey = int.Parse(navigationContext.Parameters["MailItemKey"]);
}
If you want to pass custom objects - it will be more complex. I would look for MVVM in the box samples - there is some code on how it's done. I had to re-work it whole lot and code is not really copy-pasteable.
Sounds like a perfect use of a RegionContext.
Parent view contains a region that can have multiple "child" views activated in it. They need to share some context or data. Set a region context and bind or pass whatever info all the "child" views in the Region will need.
See the Prism samples around RegionContext.

Persist Data Between Actions when using Action Stack in Zend

I am designing a web application with a left sidebar. Each of my actions has its own widgets which must be loaded into the sidebar, and in some cases multiple actions are stacked using the Action Stack plugin. When all actions have finished running I need to 'normalise' and manipulate the number of widgets, then render them.
At this stage I am thinking that:
Each action should store its list of sidebar widgets with the view, and
A front controller plug-in with a dispatch loop shutdown event should take the list from the view and operate on it
Does this sound reasonable? Is there a better way?
I wondered whether I should be storing the list of sidebar widgets with the response object directly, but I don't think this object allows user variables, does it?
Your thoughts are much appreciated! Yeehhaa!
Ok, so I ended up defining a list of widgets in an array for each controller, then modifying it where required in each action. But now I am in the process of moving more logic into the model, so no doubt will all change.
I have been reading about the evils of the ActionStack and now that I have my head around how to go about things without the action stack, life is much simpler!

Resources