I'm developing a SharePoint publishing site and setting up its content types and page layouts. I need to display the value for a Year field with type Number. The markup currently is:
<SharePointWebControls:NumberField FieldName="Year" runat="server" id="Year" />
The problem with the default behaviour is that it shows each number with a comma, e.g. "2,009" instead of "2009". Is there a way I can set some sort of String.Format syntax on the field to make it display correctly?
I tried creating a new rendering template which looks like this:
<SharePoint:RenderingTemplate ID="YearNumberField" runat="server">
<Template>
<SharePoint:FormField ID="TextField" runat="server"/>
</Template>
</SharePoint:RenderingTemplate>
... but there doesn't appear to be any 'Format' property on the FormField object.
Thanks for any help.
Update:
I tried wrapping the SharePoint:FormField tag inside SharePoint:FormattedString. Unfortunately the field was not formatted, same results as this question.
The issue is that the rendering template must use FormField. This always renders the value in the format: 1,989 . To resolve this the rendered text needs to be trapped and altered to get the desired output. Here are two approaches to resolving this:
1. Write a custom control inherited from NumberField
The RenderFieldForDisplay and RenderFieldForInput methods can be overridden to provide the desired output. Additional properties can be added to the control to describe additional behaviour.
Pros: No changes to rendering templates required.
2. Write a custom control for use in the rendering template
A control that (for example) uses regular expressions to alter text can wrap around the FormField control.
<SharePoint:RenderingTemplate ID="YearField" runat="server">
<Template>
<RX:RegexManipulatorControl runat="server"
Mode="Replace"
Expression=","
Replacement="">
<SharePoint:FormField runat="server"/>
</RX:RegexManipulatorControl>
</Template>
</SharePoint:RenderingTemplate>
Pros: Generic solution can be used for any type of field.
from Just Another SharePoint Blog
Open the list view in SharePoint
Designer.
Right click on the data view web part.
(the list)
Select Convert to XSLT Data View
Click on the number field you would
like to format
A > will appear showing Data Field,
Format As
Click on the link below Format As -
Number formatting options
Under Options deselect Use 1000
separator
Click OK
Save your changes and hit F12 to
preview
Related
How we can change the text of the TAB Item dynamically based on Order Type in Sales order screen.
for example: for TR order type, I want to change Document Details to Transfer Details.
To my knowledge there is no DAC binding for changing Tab Header Text from the business logic layer (graph). A possible workaround if you have a limited number of alternative Tab Header Text could be to create a tab for each of them and dynamically hide them based on your display condition.
How to hide Tabs in Acumatica:
Hiding a tab from the user interface dynamically
The other option would be to use JavaScript to change the inner element of the Tab Header Control.
Both options are less than ideal and can have an impact if you're looking to have your customization certified by Acumatica but if it's a hard requirement that's the only ways to do it that I'm aware of.
In the following example I'm using the hardcoded HTML Control ID for the Tab Header Control that I looked up using the Inspect Element feature provided by HTML browsers:
<asp:Content ID="cont1" ContentPlaceHolderID="phDS" Runat="Server">
<script type="text/javascript">
$(function() {
$(document)
.ready(function() {
document.getElementById("ctl00_phG_tab_tab0").innerHTML = "My Tab Header Text";
});
});
</script>
[...]
</asp:Content>
Is there any possibility to make an editbox in xpages that looks like an editable field - notes style from Lotus Notes? Or to be able to display the field value in more lines, if it necessary ?
I tried adding Auto for the editbox, but it no works.
rows and cols properties allow you to change the size. You can also use Dojo Simple Text Area or Dojo Text Area controls from Ext Lib. The latter auto-expands depending on the content, so rows and cols are not applicable (see the part in XPages Extension Library book on that).
If you're talking about the field handles round the top left and bottom right of a field, I don't think web development supports partial borders. It will be a generic CSS web development solution you require, rather than anything specific to XPages.
I know this is kind of late but here's what I came up with:
https://codepen.io/gcoxdev/pen/MmdrYz
<div class="notes-field">
<div class="notes-editable contenteditable="true"></div>
<textarea name="test"></textarea>
</div>
Of course, you'll have to convert that to xpages markup.
Essentially I'm creating a content-editable div with unicode characters for the handles then updating the underlying textarea with javascript.
You can read my article about it here:
http://gcoxdev.com/xpages-notes-style-field
Hope that helps!
Is there a way how to adjust HTML generated by xPage from document rich text field? I have q document from which the rich text field content is displayed on xPage using computed text control. Solution works nice except, that xPages engine generates strange HTML from the rich text field. When displaying page on web using standard form, all texts written by default font and default size doesn't contain markup arround so on could use CSS to style it. Not this way in xPages. Everything have tag around and its not funny seeing generated font tag around the div tag :-(
<div class="tcl-columns3-in">
<font size="2" face="sans-serif"></font>
<font size="2" face="sans-serif">
<b>Header text ...</b>
</font>
<font size="2" face="sans-serif">
<div class="tcl-box-outlined">
text ...<br>
</div>
</font>
</div>
Is there a way how to get rid of out of generated HTML?. I looked to html filtering option with ASF filter but it requires to adjust settings on filesystem, which not option for me ...
There are a number of steps you narrow down your problem. RichText -> MIME -> RichText is not a problem free relationship. As Carl pointed out, you can have a look at the raw RichText -> Mime conversion result. Does that look OK? Then you could use a Dijit ContentPane to pull that content in.
It also depends on what control you use to display the content. You might have different success with textbox and RichText editor. If you look for very high fidelity you either store your RT as mime (a property of a RT field) or use Coex Edit a commercial server plug-in
use a computedField in your Xapge, and set the value to something like this
var rt = document1.getDocument().getFirstItem("Body");
return rt.getUnformattedText()
using this technique you can also format the content the way you like as it is all text. I use this to display colored and formatted json and xml
I'm working on a custom Display Form for a SharePoint list. Is there a way to get the field choices for a field that has multiple choices? That is, I can print out the chosen value with something like:
<xsl:value-of select="#Migration_x0020_Status" />
But, I want to print out all the choices, including the one that was chosen. The closest I've come is to use the FormField element from the EditForm page like the following:
<SharePoint:FormField runat="server" id="ff4{$Pos}" ControlMode="Edit" FieldName="Migration_x0020_Status" />
However, that prints out SELECT and OPTION elements. I want to get the underlying choices and print out my own stuff (eg: with UL and LI elements). How can I do this?
i would suggest to use object model to create a custom webpart for the same. if thats not the CHOICE I would like to suggest a slight change in your architecture to include lookup column and then in your xslt datasource add the master list data source as well and then work on xslt to show it the way you want
I am following the example given here to override the default DocumentLibraryForm rendering template
MSDN - Override a Default Control Template
<SharePoint:RenderingTemplate ID="DocumentLibraryForm" runat="server">
... Custom stuff here ..
</SharePoint:RenderingTemplate>
(Thats the 2007 version, the 2010 version is the same but not complete, it doesn't show the directives)
And that all works just fine. There are lots of other examples on t'internet of overriding control rendering templates.
However I am trying to override things like ListTitleViewSelectorMenu and that isn't working.
<!-- Definition from allitems.aspx -->
<SharePoint:ListTitleViewSelectorMenu AlignToParent="true" id="LTViewSelectorMenu" runat="server" />
SharePoint:RenderingTemplate can only be used to override defined templates, usually in the generation of forms and list views. I dont think they can be used to replace random controls that are placed on page layouts.
I think i have tried what you are trying do, customise that view dropdown on list layout pages. I have an control that shows it sorted. The way that you replace controls is with a DelegateControl (http://msdn.microsoft.com/en-us/library/ms470880.aspx), but unfortuately ListTitleViewSelectorMenu is not wrapped by a DelegateControl in the standard list layouts. You may have to replace the entire bread crumb.