FormatGrid
Johannes Geppert edited this page Aug 5, 2015
·
2 revisions
There are several predefined formatter available. For details about each formatter and the format options please take a look into the jqGrid Wiki.
<sjg:gridColumn
name="creditLimit"
...
formatter="currency"
...
/>
<sjg:gridColumn
name="id"
key="true"
...
formatter="integer"
...
/>
The following example shows how to format a date. The JSON result give us a date formatted like this "Y-m-d H:i:s'" and now we want to show this in e.g. German date format.
<sjg:gridColumn
name="dateColumn"
...
formatter="date"
formatoptions="{newformat : 'd.m.Y H:i', srcformat : 'Y-m-d H:i:s'}"
...
/>
This example is taken form the Grid Showcase. This steps describe how to open an custom dialog from a grid column.
<sj:dialog
id="employees_details"
title="Employee Details"
autoOpen="false"
modal="true"
width="400"
>
- Create an URL to struts2 action
- Create a function that formats your column
- Create a function which loads and open your dialog
<s:url var="empurl" action="employees-detail" />
<script type="text/javascript">
function formatLink(cellvalue, options, rowObject) {
return "<a href='#' onClick='javascript:openDialog("+cellvalue+")'>" + cellvalue + "</a>";
}
function openDialog(employee) {
$("#employees_details").load("<s:property value="empurl"/>?id="+employee);
$("#employees_details").dialog('open');
}
</script>
<sjg:gridColumn
name="salesemployee.employeenumber"
index="employeenumber"
title="Employee"
...
formatter="formatLink"
...
/>
- Home
- Ajax
- UI widgets
- UI interactions
- Resizable for Divs
- Drag and Drop for Divs
- Selectable for Divs
- Sortable for Divs
- Form Elements
- Tasks