Edit method Set parameter is not setting to true in check box control - microsoft-dynamics

I am using edit method on a form Check box control in a Grid and data source is a view. The parameter in _set boolean is not setting to true when we clicked on the check box. The code in the edit method is as follows.
edit NoYes markNow(
boolean _set,
VendInvoiceProdReceiptNotInvoicedView _vendInvoiceProdReceiptNotInvoicedViewLocal,
NoYes _markNow)
{
if (_set)
{
if (_markNow)
{
matchedReceipts.insert(_vendInvoiceProdReceiptNotInvoicedViewLocal.VendPackingSlipJourRecId, _vendInvoiceProdReceiptNotInvoicedViewLocal.PackingSlipId);
}
else
{
if (matchedReceipts.exists(_vendInvoiceProdReceiptNotInvoicedViewLocal.VendPackingSlipJourRecId))
{
matchedReceipts.remove(_vendInvoiceProdReceiptNotInvoicedViewLocal.VendPackingSlipJourRecId);
}
}
this.refresh();
}
return matchedReceipts.exists(_vendInvoiceProdReceiptNotInvoicedViewLocal.VendPackingSlipJourRecId) ? NoYes::Yes : NoYes::No;
}
Could you please help me with this.

Edit methods cannot be used on top of Views as data source, Use regular table as data source.

Related

Loopback: Hide some properties for some user roles

There is a model like this
{
name,
budget
}
And there is a role reviewer
Is there any way to hide the budget field for the reviewers?
You can use a remote hook for that model. For example your code could look like this:
MyModel.afterRemote('**', function(ctx, modelInstance, next) {
if (ctx.result) {
if (checkIfUserHasRole('reviewer')) { // <-- you need to implement this function
// if you are going to return a list of items, eg. from Model.find(...)
if (Array.isArray(modelInstance)) {
ctx.result = ctx.result.map(item => {
return modifyYourProperties(item); // <-- you need to implement this function
}
}
// if you are going to return a single item, eg. from Model.findById(...)
else {
ctx.result = modifyYourProperties(ctx.result); // <-- as above...
}
});
}
}
next();
}
So now, on every remote call to your model, you can modify the results. They are already processed but not yet returned to the requester, so here is where you can hide desired properties.
Of course, you need to implement methods checkIfUserHasRole and modifyYourProperties to do what you are going to achieve. You can read more about remote hooks here: https://loopback.io/doc/en/lb3/Remote-hooks.html

CTabView how to prevent switching

I use CTabView thats hold different FormViews.
I can switch to another view without any problem.
From a ParamView I don't want to allow switch to another view until the changed value are confirmed.
I have tried it with OnActivateView(..), OnShowWindow(..). But they are too late, the view are already moved to a another view, then these handlers are fired. :(
void CParamView::OnActivateView(BOOL bActivate, CView* pActivateView, CView* pDeactiveView)
{
/* // did not work, next View already shown before
if (!bActivate && pActivateView != pDeactiveView)
{
if (ParamValueChanged())
{
if (!ConfirmChangedValues())
return;
}
}
*/
CFormView::OnActivateView(bActivate, pActivateView, pDeactiveView);
}

Sitecore Set the Number of Components

Is it possible to set the number of components in placeholder?
We can add as many as components in placeholder by using "Add to here" in gray box even the component has been already added.
I'd like to say that
In plcaceholder named 'bodyArea', you can set only one component in 'bodyArea' placeholder and you will not add any other component additionally.
Is there anyway how to do this??
There could be many ways, but this is what I used before.
// Check the number of renderings in placeholder
public static bool numberOfRenderings(string placeholderName)
{
bool rendering = true;
var renderingReferences = Sitecore.Context.Item.Visualization.GetRenderings(Sitecore.Context.Device, true);
int renderingsInPlaceholder = renderingReferences.Where(r => r.Placeholder.EndsWith('/' + placeholderName, StringComparison.OrdinalIgnoreCase)).Count();
if (renderingsInPlaceholder > 1)
{
return rendering = false;
}
return rendering;
}
In View.cshtml
if (#yourObject.numberOfRenderings("your-placeholder-key")) {
#Html.Sitecore().Placeholder("your-placeholder-key")
}
else
{
#Html.Raw("<div>Only one rendering item is available in this placeholder.</div>")
}
here is a blog where is describing how to restrict number of allowed controls :
http://www.newguid.net/sitecore/2014/restricting-the-number-of-components-in-the-sitecore-page-editor/
Other solution is using rules :
http://dotnetmafia.com/blogs/kevin/archive/2013/07/10/placeholder-settings-rules.aspx

Hiding / showing markers: OSMDroid / OpenMaps

I have an app which uses or googlemaps or openMaps (offline) depending of connection state.
In each case there are markers, for places or point of interest or… I want that the user can display or hide some category of markers.
When using google maps I have a menu and in the action bar when some item is selected it toggles between showing or hiding the markers from the correpondent category; As for google maps that works easily & perfectly using isVisible();
As for osmdroid i have not found in the doc any equivalent to isVisible(), neither any show() or hide() method. So I have tried to use as a workaround somemarkers.getAlpha() & somemarkers.setAlpha(), toggling between 0 & 1 alpha values.
No error occurs but the visibility of markers remains the same, not toggling, or only randomly when i tap 10 or 20 times on the action icon.
In the log i get "InputEventReceiver: Attempted to finish an input event but the input event receiver has already been disposed" which seems to me to be the cause.
But what to do to avoid this?
KitKat, SonyXperia Z
In osmdroid, the method to hide/show overlays (markers) is:
Overlay.setEnabled(boolean enabled)
I have done this bit differently.
Extend ItemizedIconOverlay
Add as an overlay to mapView
Hide markers by using removeAllItems or removeItem
Show marker by adding it to the itemized overlay list
Create a new Overlay class by extending ItemizedIconOverlay.
Note: WaypointOverlayItem extends OverlayItem. {It's your custom overlay model class}
public class NavigatorItemizedOverlay extends ItemizedIconOverlay<WaypointOverlayItem> {
private Context mContext;
public NavigatorItemizedOverlay(final Context context, final List<WaypointOverlayItem> aList) {
super(context, aList, new OnItemGestureListener<WaypointOverlayItem>() {
#Override
public boolean onItemSingleTapUp(int index, WaypointOverlayItem item) {
return false;
}
#Override
public boolean onItemLongPress(int index, WaypointOverlayItem item) {
return false;
}
});
// TODO Auto-generated constructor stub
mContext = context;
}
}
Add this Overlay to your map
//Add Itemized overlay
navigatorItemizedOverlay = new NavigatorItemizedOverlay(getActivity(), waypointOverlayItemList);
mapView.getOverlays().add(navigatorItemizedOverlay);
To Add marker:
navigatorItemizedOverlay.addItem(waypointOverlayItem);
To hide all markers:
navigatorItemizedOverlay.removeAllItems();
There are other methods:
removeItem(position) and removeItem(waypointOverlayItem)

Passing parameters in Ember's Custom Events (that bubble through the View hierarchy)?

I couldn't find a way to pass arguments when using Ember's Custom Events which I found here.
I prefer avoiding solutions which target "parent" views specifically, such as this one since we lose the "bubbling".
My Usage is as following
plugins.js
Em.Object.reopen({
triggerEvent: function (eventName) {
this.$().trigger(eventName, this);
}
});
MyView.js
click: function () {
this.triggerEvent('stepClicked');
}
The code in Ember (0.96+) shows that passing an additional params is considered a manager, which isn't passed on
rootElement.delegate('.ember-view', event + '.ember', function(evt, triggeringManager) {
...
if (manager && manager !== triggeringManager) {
result = self._dispatchEvent(manager, evt, eventName, view);
} else if (view) {
result = self._bubbleEvent(view,evt,eventName);
}
Super thanks in advance,
Oren Rubin
You can pass an event object which will tell you what element is being clicked on:
click: function(event){
// will be called when when an instance's
// rendered element is clicked
console.log("element clicked: " + this.get('elementId') );
return false; // return true if you want the click event to bubble up to parent view (default it true)
}
I think an even better way would be to use {{action}} in your template. Take a look at this answer for an example.