0

I have a listview web part page that on submission creates a new item in a custom list. One of the fields in that list is a multiple choice field which renders as checkboxes on my new item page. In the xsl this is a single line

<SharePoint:FormField runat="server" id="ff3{$Pos}" ControlMode="New" FieldName="Award_x0020_Category" __designer:bind="{ddwrt:DataBind('i',concat('ff3',$Pos),'Value','ValueChanged','ID',ddwrt:EscapeDelims(string(@ID)),'@Award_x0020_Category')}" />

I'd like to be able to give this a customised look and feel, ie. alternating line colours and preferably some accordion effects with jquery. I don't think its actually possible to do anything like that with the web part but a workaround I'd though of is: '

  1. create an HTML form web part that does all the stuff I want it to and has checkboxes with the same values as the list choices.
  2. hide the list view web part.
  3. pass the values of the html web part check box to the dataview we part checkbox, either on submit, or when the box is selected.

Is this possible and if so how would I go about doing it?

Cheers

1 Answer 1

0

In fact form fields formatting for choice field could be performed on the client side.

How to customize multiple choice field formatting (alternate colors) via JavaScript

function applyFormatting(fieldInternalName){
    var containerId = getChoiceFieldContainerId(fieldInternalName);
    $("table#" + containerId + " tr:even").css("background-color", "#F4C4F8");
    $("table#" + containerId + " tr:odd").css("background-color", "#EFF1F1");
}


function getChoiceFieldContainerId(fieldInternalName)
{
    var choiceFieldContainer = $('table[id^="' + fieldInternalName + '"]');
    return choiceFieldContainer.attr('id');   
}

var fieldInternalName = 'Award_x0020_Category';
applyFormatting(fieldInternalName);

enter image description here

Usage:

  1. Add Content Editor web part (CEWP) on form page (New Form - NewForm.aspx)
  2. Insert the specified code

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.