Skip to content

Commit

Permalink
#967 add an option to specify the width of the colums
Browse files Browse the repository at this point in the history
  • Loading branch information
stephanrauh committed Jul 27, 2018
1 parent 823e171 commit 0654ec6
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,13 @@ private void generateHeader(FacesContext context, DataTable dataTable, ResponseW
}
}

if (column.getAttributes().get("width") != null) {
String width = column.getAttributes().get("width").toString();
if (isNumeric(width)) {
width+= "px";
}
updateColumnDefinition(dataTable, index, "'width':'" + width + "'");
}

if (column.getAttributes().get("customOptions") != null) {
String customOptions = column.getAttributes().get("customOptions").toString();
Expand Down Expand Up @@ -860,4 +867,13 @@ protected void updateColumnDefinition(DataTable dataTable, int index, String val

}

public static boolean isNumeric(String str)
{
for (char c : str.toCharArray())
{
if (!Character.isDigit(c)) return false;
}
return true;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -24,26 +24,7 @@
public abstract class DataTableColumnCore extends UIColumn {

protected enum PropertyKeys {
contentStyle,
contentStyleClass,
customOptions,
dataOrder,
dataSearch,
dataType,
footerStyle,
footerStyleClass,
headerStyle,
headerStyleClass,
label,
labelStyle,
labelStyleClass,
order,
orderBy,
orderable,
searchValue,
searchable,
style,
styleClass;
contentStyle, contentStyleClass, customOptions, dataOrder, dataSearch, dataType, footerStyle, footerStyleClass, headerStyle, headerStyleClass, label, labelStyle, labelStyleClass, order, orderBy, orderable, searchValue, searchable, style, styleClass, width;
String toString;

PropertyKeys(String toString) {
Expand Down Expand Up @@ -378,4 +359,20 @@ public void setStyleClass(String _styleClass) {
getStateHelper().put(PropertyKeys.styleClass, _styleClass);
}

/**
* Width of the column. If you don't specify the unit, BootsFaces assumes you want to use 'px'. You can use the other units by adding them to the value, such as '50%', '5em', '16vw', etc. <P>
* @return Returns the value of the attribute, or null, if it hasn't been set by the JSF file.
*/
public String getWidth() {
return (String) getStateHelper().eval(PropertyKeys.width);
}

/**
* Width of the column. If you don't specify the unit, BootsFaces assumes you want to use 'px'. You can use the other units by adding them to the value, such as '50%', '5em', '16vw', etc. <P>
* Usually this method is called internally by the JSF engine.
*/
public void setWidth(String _width) {
getStateHelper().put(PropertyKeys.width, _width);
}

}
6 changes: 6 additions & 0 deletions src/main/meta/META-INF/bootsfaces-b.taglib.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7129,6 +7129,12 @@
<required>false</required>
<type>java.lang.String</type>
</attribute>
<attribute>
<description><![CDATA[Width of the column. If you don't specify the unit, BootsFaces assumes you want to use 'px'. You can use the other units by adding them to the value, such as '50%', '5em', '16vw', etc.]]></description>
<name>width</name>
<required>false</required>
<type>java.lang.String</type>
</attribute>
</tag>

<!-- *********** b:datepicker ************************* -->
Expand Down
1 change: 1 addition & 0 deletions xtext/BootsFaces.jsfdsl
Original file line number Diff line number Diff line change
Expand Up @@ -628,6 +628,7 @@ widget dataTableColumn {
orderable Boolean default "true" "Disables or enables the sort button for this column."
searchable Boolean default "true" "If set to false, this column is excluded from the multi-column-search feature of b:dataTable. Defaults to true. Note that this feature is active only if both searching='true' and multi-column-search='true' are set on the datatable."
value inherited "EL expression referring to the back-end bean attribute providing the value of the field."
width "Width of the column. If you don't specify the unit, BootsFaces assumes you want to use 'px'. You can use the other units by adding them to the value, such as '50%', '5em', '16vw', etc."
+style
}

Expand Down

0 comments on commit 0654ec6

Please sign in to comment.