Posts tonen met het label Custom. Alle posts tonen
Posts tonen met het label Custom. Alle posts tonen

dinsdag 6 november 2012

Horizontal alignment of Choise Fields


This week I found a way to change the alignment of a Choice Field.
Nice to know if you have list of questions where somebody has to choose
between for example three answers. 

You only have to make a custom New/Edit page in Sharepoint Designer
and add the next line
<xsl:comment>FieldName="Display Name"</xsl:comment>                                                          
just before the sharepoint Formfield definition <SharePoint:FormField …

Change the "Display Name" by the display name of your Sharepoint Field.

Add a Content Editor webpart to your page and 
put the next Jquery script in this webpart.


<script>
$( document ).ready( function() {
// columnName = Field Display Name
// perRow = how many choices you want to see in one row.
            $().SPServices.SPArrangeChoices({
                        columnName : "Display Name",
                        perRow: 3
                        });
});
</script>
 

donderdag 11 oktober 2012

Check if Sharepoint Richt Text Editor Field is empty or not (works in IE, Firefox and Chrome)


Found out this week that the code for checking the content of a multi-line rich text field was 
not working for other than IE-browsers.
So after some debugging in Chrome I found a solution that works in Chrome and in Firefox.
I hope that it's also working in other browsers... but I don't have them to my position at work.
Have fun with my new code... 



 firefox/chrome bugfix...
    var scomments = "";
    if ($.browser.msie) 
 {     
  // IE browser, check on language needed because Sharepoint and IE Translates the IFrame name in different languages.   
  if (_spPageContextInfo.currentLanguage == 1036) 
  {
            var systemDescriptionRTE = $("textarea[title='Comments']").closest("span").find("iframe[Title='Éditeur de texte enrichi']").contents().find("body");
            scomments = $(systemDescriptionRTE).text();
        }
        else
        {
            if (_spPageContextInfo.currentLanguage == 1043) 
   {
                var systemDescriptionRTE = $("textarea[title='Comments']").closest("span").find("iframe[Title='RTF-editor']").contents().find("body");
                scomments = $(systemDescriptionRTE).text();
            }
            else
            {
                var systemDescriptionRTE = $("textarea[title='Comments']").closest("span").find("iframe[Title='Rich Text Editor']").contents().find("body");
                scomments = $(systemDescriptionRTE).text();
            }
        }
 }
 else
 {
 // if other browser
        var systemDescriptionRTETextArea = $("textarea[Title='Comments']"); 
        scomments = $(systemDescriptionRTETextArea).val(); 
 }
  

Now you can check with the 'scomments' variable is it is empty or containing some values.

zondag 15 april 2012

Check if Rich TextField is Empty


Last week I had some problems to do a check wether a Rich Text Box is filled in or not. 
When doing a check on the Text propertie of the TextField, 
I found out that Sharepoint puts default something in the TextField. 

Like it or not, but it's really frustrating that you can't use the JQuery test .isEmpty().
So after some testing, I found out that Sharepoint puts a Paragraph tag in the TextField. 
So here under you can found out how I did the check wether a Rich TextField is filled in or not. 
 

if( ($(ctl00_m_g_6e043a15_d2d5_4e91_a8c6_562e51fe3b46_ff121_ctl00_ctl00_TextField_inplacerte).text() == "") || ($(ctl00_m_g_6e043a15_d2d5_4e91_a8c6_562e51fe3b46_ff121_ctl00_ctl00_TextField_inplacerte).html() == "

?

") ) { alert('Please fill in the Rich Text box field !'); return false; }

zaterdag 31 maart 2012

Custom Cancel button, Go Back to the web-page you came from ...

Nice to have against the Close or Save button is a beautifull Cancel button. 
A request of a customer this week was to have a link on there intranet 
to a sharepoint custom new page, but without the Sharepoint header and menu. 

So people could add items in a list, but nothing else more. 

On the page the Sharepoint Close/Cancel button returns automatically back to 
the Sharepoint List. But what the customer wanted was that the requester 
returned back to the page where they came from or, 
if the page was openend in a new window, to close the window.

To do this, replace the Sharepoint Close/Cancel button with our own custum buttom.
add a little script in a content Editor webpart to execute the return function (goback).



<input type="button" value="Cancel" name="CancelButton" class="ms-ButtonHeightWidth" onclick="goback();" />

// in content editor webpart:
function goback() {
    // Jumps back
            //history.back();
            if (history.length >0)
            {
                        history.back();
            }
            else
            {
                        window.close();
            }
}

 

dinsdag 21 februari 2012

Give Custom Save button with Sharepoint Layout and Redirection

People are adding custom controls to there sharepoint pages, but the buttons doesn't have 
the same look and feel as the one Sharepoints generates itselfs. 
But I wouldn't be a developer to give you a solution with gives you your buttons the same
look and feel as the Sharepoint buttons. 

To get this, you must not add a HTML Button element, but a Input element of the type button.
For giving it the same look and feel of Sharepoint Buttons you have to 
add a Sharepoint CSS class named "ms-ButtonHeightWidth"

In the example below you have a Button that you can use instead of the generated Save button 
and that redirects your page after saving your content to an other location 
than the standard view of your list in Sharepoint.
For the redirection you have to add some code that generates an event after a succesfull SaveAction.
 



<input type="button" value="Save" name="SaveButton" class="ms-ButtonHeightWidth" onclick="if (!PreSaveAction()) return false;{ddwrt:GenFireServerEvent('__commit;__redirect={<<SITE URL TO REDIRECT>>};')}" />