Orchard CMS. How correct display shape in zone? - orchardcms

I have a module Orchard.MyModule. In module is shape Orchard.Web\Modules\Orchard.MyModule\Views\Parts\Header.cshtml
in Header.cshtml is code
...
Model.ContentItem.Id
...
If in layout.cshtml
Func<dynamic, dynamic> Zone = x => Display(x);
#if(Model.Header != null)
{
#Zone(Model.Header)
}
Always yellow page of death and Model.ContentItem = null.
If in layout.cshtml delete it code, then will be situations:
1) In admin panel set in Header zone widget Header.cshtml. --- NOT DISPLAY
2) In admin panel in Header zone empty, Header.cshtml in BeforeContent zone. --- Header shape(Header.cshtml) will be displayed
3) All zones empty. --- NOT DISPLAY
Shape Header.cshtml redefines Header zone? How insert in Header zone Header.cshtml and display it correctly?

I assume Parts/Header.cshtml is being displayed by a driver.
protected override DriverResult Display(MyPart part, string displayType, dynamic shapeHelper) {
return ContentShape("Parts_Header", () => shapeHelper.Parts_Header();
}
Something like this?
Then you can take the shape type (ie the first argument in ContentShape: "Parts_Header") and send this part to the main layout zone in your modules Placement.info like this:
<Place Parts_Header="/Header:1" />
The import part being the / before Header, which tells Orchard this shape should be displayed in the main layout zone

Related

Trying to customize JAMS LaborEntry screen, looking for the line of code that will update the header

Brand new to Acumatica development and stuck on a simple thing. :(
I am customizing the LaborEntry screen of the JAMS MFG.
I have added a field to the header by extending the AMBatch DAC, called UsrTimeClocked.
For now I simply wish to set this field to a number right at the end of the RowInserted event at the detail level of the AMMTran and see my number on the screen, up on the header AMBatch.
public class LaborEntry_Extension : PXGraphExtension<LaborEntry>
{
protected virtual void _(Events.RowInserted<AMMTran> e)
{
AMBatchExt ext = Base.batch.Current.GetExtension<AMBatchExt>();
ext.UsrTimeClocked = 5.32;
//Insert line to update the correct object to see 5.32 in the TextBox, before RowSelected is done.
}
}
As is my value goes in the field and any refresh/save/delete of the row does update the correct object and I see my value where I want it. I wish to know the way to force this update.

Dynamically changing field's DisplayName affests web service

The field in the DAC is defined like this.
#region NextMonthHours
[PXDBDecimal(2, MinValue = 0.0, MaxValue = 280.0)]
[PXUIField(DisplayName = "Next Month Hours")]
[PXDefault(TypeCode.Decimal, "0.0")]
public virtual Decimal? NextMonthHours { get; set; }
public abstract class nextMonthHours : PX.Data.BQL.BqlDecimal.Field<nextMonthHours> { }
#endregion
I change the display name of the field in RowSelected event.
PXUIFieldAttribute.SetDisplayName<EVEPPlannedHoursDetails.nextMonthHours>(sender, nextMonth+"Hours");
where nextMonth is "February".
I need to add this field to Acumatica Mobile Screen. When I go to web service schema the field name is "FebruaryHours"
<s:element minOccurs="0" maxOccurs="1" name="FebruaryHours" type="tns:Field"/>
I cannot use the name "FebruaryHours" because it changes every month but I also when I use field name NextMonthHours it is not added in the mobile screen.
Any idea how to solve this issue?
Thanks
There's quite a few ways to workaround this depending on the use case and whether the label value is static or dynamic.
If all you want to do is to change a static label in UI without having to change the display name property you can add a separate label and merge group.
Here's an example to change Billable in UI without changing DisplayName property using that technique.
Set SuppressLabel property to true to hide the original label bounded to DisplayName on UI.
Use ADD CONTROLS tab to add a Layout Rule with Merge property set to true.
Use ADD CONTROLS tab to add a label control in the merged group.
Put the original field in the merge group so they show up together on the same line in UI.
End result, label is now a UI control and wouldn't interfere with DisplayName property.

SharePoint Online - Show/display column in default view

I am adding a site column into a document library default view and want it to be visible/shown when you click onto the list itself. However, I am unsure on how to do this. The code I have so far
// Get the view (this is the default view)
Microsoft.SharePoint.Client.View v = Employeecvlist.GetViewByName("All Documents");
// Load it up
clientContext.Load(v, x => x.ViewFields);
clientContext.ExecuteQuery();
// Get the field I want to add to the view
Microsoft.SharePoint.Client.Field name =
Employeecvlist.Fields.GetByInternalNameOrTitle("Name");
clientContext.Load(name);
clientContext.ExecuteQuery();
// Add this field to the view !! Nothing else in the view object to allow to make it visible by default !!
v.ViewFields.Add(name.InternalName);
// Finally, update the view
v.Update();
If you look at the image file below, I basically want to be able to check the "display" checkbox to true for the above field.
Can someone point me into the right direction?
Thanks
You need to perform clientContext.ExecuteQuery() again to persist the changes. Also, there's no need to do it twice to load your objects, load everything you need and then get it from the server:
//Put following line in the using section
using Microsoft.SharePoint.Client;
//Your code
View v = Employeecvlist.GetViewByName("All Documents");
Field name = Employeecvlist.Fields.GetByInternalNameOrTitle("Name");
clientContext.Load(v, x => x.ViewFields);
clientContext.Load(name);
v.ViewFields.Add(name.InternalName);
v.Update();
clientContext.ExecuteQuery();

Custom selector challenges

I have a custom screen with a multiple custom selectors, which change what they select based on dropdown lists.
The solution I implemented is shown in a previous case:
Dynamically changing PXSelector in Acumatica (thanks).
My challenge is twofold:
1.) If the dropdown selection is "No Lookup", then I want the PXSelector Attribute to essentially be removed - leaving just a text entry. Not sure if this is even possible...
2.) If one of the selectors (let's say Projects) is selected, I'd like the selection of the following selector (let's say Tasks) to filter based on the Project selected.
Thanks much...
1) I think the only way to do this is to create your own attribute.
Something like that:
public class PXSelectorTextEditAttribute : PXSelectorAttribute
{
bool selectorMode;
public PXSelectorTextEditAttribute(Type type, bool selectorOn):base(type)
{
selectorMode = selectorOn;
}
public override void FieldVerifying(PXCache sender, PXFieldVerifyingEventArgs e)
{
if(selectorMode)
base.FieldVerifying(sender, e);
}
public static void SwitchSelectorMode(PXSelectorTextEditAttribute attribute, bool onOff)
{
attribute.selectorMode = onOff;
}
}
You will be able to turn on and off the 'selector' part of the attribute. With the field verifying turned off you will be able to put any value to the field just like in simple TextEdit field. However, the lookup button in the right end of the field still will be visible. I have no idea how to hide it.
2) This behavior can be implemented easily. You will need something like that(example based on cashaccount):
[PXSelector(typeof(Search<CABankTran.tranID, Where<CABankTran.cashAccountID, Equal<Current<Filter.cashAccountID>>>>))]
If you want to see all records when the cashaccount is not defined then you just modify the where clause by adding Or<Current<Filter.cashAccountID>, isNull>
Also don't forget to add AutoRefresh="true" to the PXSelector in the aspx. Without it your selector will keep the list of the records untill you press refresh inside of it.

Multiple items in MonTouch.Dialog section header

Based on Miguel's response to another question (see below) I was able to get a label in my section header. But I'm looking to take it a little further with 3 lines of text. My first thought is instead of creating the header with a single label, is there a way to create it with a uiview where inside that view you can place whatever items you want?
Section headers and footers can either be specified as strings or UIViews, there is sadly, nothing in between.
If you want to have custom headers/views, you would need to create a UILabel and use that in your constructor to the Section type (only available for the Elements API).
Something like:
var header = new UILabel (new RectangleF (0, 0, 320, 48)){
Font = UIFont.BoldSystemFontOfSize (22),
BackgroundColor = UIColor.Red
}
new Section(header, footer) {
...
}
Yes, you can.
The parameters to the Section constructor are either two strings of text, or two UIViews. In the sample above you merely created a UIView of type UILabel, but it could be anything you want, with as many subviews as you want or need.

Resources