Radiobuttons Horizontal align

Discussions about Forms Designer for SharePoint 2013 / 2016 and Office 365.
Vinay Muppidi
Posts: 9
Joined: Mon Jun 02, 2014
Contact:

11 Jul 2014

<div class="ms-formbody fd_control" fd_readonly="False" style="margin-left: 160px;" fd_type="RadioButtons">


How do I align the radio buttons horizontally on the form? Please advise.

User avatar
Dmitry Kozlov
Site Admin
Posts: 1524
Joined: Thu Jun 07, 2012

14 Jul 2014

Please, try the following code:

Code: Select all

var rows = fd.field('Choice').control()._el().find('table tr td');
fd.field('Choice')
	.control()
	._el()
	.find('table > tbody')
	.empty()
	.append($('<tr />').append(rows));
Replace 'Choice' with the internal name of your field.

Vinay Muppidi
Posts: 9
Joined: Mon Jun 02, 2014
Contact:

14 Jul 2014

Thanks Dimitry ..works perfect!

Sonoma
Posts: 88
Joined: Wed Oct 15, 2014

07 Oct 2014

Thank you for this. Is there any way to group them radio buttons or check boxes.



e.g. 3X3

O A O D O G

O B O E O H

O C O F O Other



another 3X2X3 as in daysm nonths years, etc. Below is an example of one multi select check box called treatment. the answer could be days, Pre-trial, Pending

O days O Trial O Unknown

O weeks O Pre-Trial O Pending

O months O Constant



Thank you

User avatar
Dmitry Kozlov
Site Admin
Posts: 1524
Joined: Thu Jun 07, 2012

08 Oct 2014

Hi,

3x3 grouping:

Code: Select all

var options = fd.field('Choice').control()._el().find('td');
var content = '<table>';
for (var i = 0; i < 3; i++) {
	content += '<tr>';
	for (var j = 0; j < 3; j++) {
		content += '<td>' + options.eq(i + 3 * j).html() + '</td>';
	}
	content += '</tr>'
}
content += '</table>';
fd.field('Choice').control()._el().html(content);
Please, replace "Choice" with the internal name of your field.

If you use checkboxes as options, you'd better split them into multiple Choice fields and arrange them on the form as you need with help of Forms Designer.

Sonoma
Posts: 88
Joined: Wed Oct 15, 2014

09 Oct 2014

Thank you. Works great. I can even add my borders ( class=my-table). I am mainly using radios.


Anyway to kick out the "undefined" if you have an odd amount of objects?

User avatar
Dmitry Kozlov
Site Admin
Posts: 1524
Joined: Thu Jun 07, 2012

13 Oct 2014

Hi,

Please, try the following code:

Code: Select all

var options = fd.field('Choice').control()._el().find('td');
var content = '<table>';
for (var i = 0; i < 3; i++) {
	content += '<tr>';
	for (var j = 0; j < 3; j++) {
		if (options.length > i + 3 * j) {
			content += '<td>' + options.eq(i + 3 * j).html() + '</td>';
		} else {
			content += '<td></td>';
		}
	}
	content += '</tr>'
}
content += '</table>';
fd.field('Choice').control()._el().html(content);

Sonoma
Posts: 88
Joined: Wed Oct 15, 2014

13 Oct 2014

Perfect.

The added check allows for many configurations.



For Example I may need 5 options in one column and an "Other" with user add input box option in the other column.

var options = fd.field('Option').control()._el().find('td');
var content = '<table>';
for (var i = 0; i < 5; i++) { //Rows
content += '<tr>';
for (var j = 0; j < 6; j++) { //Columns
if (options.length > i + 5 * j) { //Rows
content += '<td>' + options.eq(i + 5 * j).html() + '</td>'; //Rows
} else {
content += '<td></td>';
}
}
content += '</tr>'
}
content += '</table>';
fd.field('Option').control()._el().html(content);

// Modify default SP text "Specify your own value:"
$("label").each(function() { if ($(this).html() == "Specify your own value:") $(this).html("Other (specify)") } )


In some cases I need 3 columns with configuration of 3 1 3. 3 and 1 are always linked in the data and the 3rd is usually seperated.


Great solution. Thank you very much.

Sonoma
Posts: 88
Joined: Wed Oct 15, 2014

07 Nov 2014

We needed something for the display form for displaying large list results from Options list allowing multiple answers to be selected that would be allow for columns and rows to be adjusted dynamically.

If I make the browser smaller the list auto adjust. and vice versa. e.g. in large screen I will have 4 columns and 5 rows and if I make is smaller I will have 2 columns and 10 rows. and is I go smaller one column and 20 rows.

I did some digging and picking and came up with this. I guess it could work with the edit and display form as well. Either way just thought I would share.


JS:

// Options list results with multiple choices allowed

var arr = fd.field('OPTION').control()._el().text().split(';');
var content = '';
$.each( arr, function( index, value ){
content += '<div class=\"list_item\">' + value + '</div>';
});
fd.field('OPTION').control()._el().html(content);



CSS:

.auto_list {
margin: 5px;
padding: 5px;
width: 300px;
float: left;
text-decoration : underline;

User avatar
Dmitry Kozlov
Site Admin
Posts: 1524
Joined: Thu Jun 07, 2012

10 Nov 2014

Great! Thanks a lot for your worthwhile sample!

Locked
  • Information
  • Who is online

    Users browsing this forum: No registered users and 22 guests