This project has moved and is read-only. For the latest updates, please go here.

Using SPServices or JQuery to change Control Mode

Apr 15, 2014 at 8:05 PM
<SharePoint:FormField runat="server" id="ff5{$Pos}" ControlMode="Display" FieldName="Location" __designer:bind="{ddwrt:DataBind('u',concat('ff5',$Pos),'Value','ValueChanged','ID',ddwrt:EscapeDelims(string(@ID)),'@Location')}"/>

My Location field needs to switch from "Display" to "Edit". Other fields need to change from "Edit" to "Display".

How do I write a JQuery or SPServices function to perform the change when the field is the only parameter?
Apr 15, 2014 at 8:11 PM

What you're looking at is the code as it runs on the server side. Before the "control" gets to the browser, SharePoint converts it into plain old HTML markup, often with some script to drive the behavior.

So what it seem you want to do is switch from displaying the current value of a field (column) to editing it, or vice versa. Usually this would be in response to some user action, like checking a checkbox in one column disabling another column. This becomes a purely JavaScript (or jQuery) exercise on the client side and has nothing to do with the original ControlMode value.

Apr 15, 2014 at 8:39 PM
Edited Apr 15, 2014 at 8:41 PM
How do I see the HTML that is rendered on the client? This not a custom web-part, so SPD doesn't reveal what EditForm.aspx is doing. Hiding a field seems pretty straightforward using tr.hide with $(onDocumentReady) ... however, changing from Edit to Display is not as clear.
Apr 16, 2014 at 1:39 AM
You can use DOM inspectors like Firebug or Internet Explorer's Developer Tools. You're right that the actual hiding is fairly simple; figuring out which element you want to hide can be trickier.

Apr 28, 2014 at 4:38 PM
<td class="ms-dtinput">
<label style="display:none" for="ctl00_m_g_7ac31d91_600f_4b8e_8e71_277b1992cc3b_ctl00_ctl05_ctl04_ctl00_ctl00_ctl04_ctl00_ctl00_DateTimeField_DateTimeFieldDate">Due Date Date</label>
<input id="ctl00_m_g_7ac31d91_600f_4b8e_8e71_277b1992cc3b_ctl00_ctl05_ctl04_ctl00_ctl00_ctl04_ctl00_ctl00_DateTimeField_DateTimeFieldDate" class="ms-input" type="text" autopostback="0" title="Due Date" maxlength="45" value="4/18/2014" name="ctl00$m$g_7ac31d91_600f_4b8e_8e71_277b1992cc3b$ctl00$ctl05$ctl04$ctl00$ctl00$ctl04$ctl00$ctl00$DateTimeField$DateTimeFieldDate">
<td class="ms-dtinput">
<a onclick="clickDatePicker("ctl00_m_g_7ac31d91_600f_4b8e_8e71_277b1992cc3b_ctl00_ctl05_ctl04_ctl00_ctl00_ctl04_ctl00_ctl00_DateTimeField_DateTimeFieldDate", "\u002fCAPA\u002f_layouts\u002fiframe.aspx?&cal=1&lcid=1033&langid=1033&tz=-05:00:00.0005187&ww=0111110&fdow=0&fwoy=0&hj=0&swn=False&minjday=109207&maxjday=2666269&date=", "2014-04-18", event);return false;" href="#">

What would the jquery look like to change this input to a display? Would spservices work better to make this change?