Permalink
Browse files

- template update

  • Loading branch information...
tudor-malene committed Feb 11, 2013
1 parent 6e5d056 commit ee1900b5c452340729083319b99d8a0cd7bb3b8a
View
@@ -1,5 +1,6 @@
#Grails Metadata file
-#Thu Feb 07 18:19:42 EET 2013
+#Mon Feb 11 18:19:51 EET 2013
app.grails.version=2.2.0
app.name=petclinic
app.version=0.1
+plugins.easygrid=1.3.0
@@ -3,7 +3,7 @@ grails.project.work.dir = "target/$grailsVersion"
grails.project.target.level = 1.6
grails.project.source.level = 1.6
-grails.plugin.location.easygrid ="../Easygrid"
+//grails.plugin.location.easygrid ="../Easygrid"
grails.project.dependency.resolution = {
inherits "global"
@@ -28,6 +28,6 @@ grails.project.dependency.resolution = {
runtime ":resources:1.1.6"
build ":tomcat:$grailsVersion"
compile ":export:1.5"
-// compile ":easygrid:1.2.1"
+ compile ":easygrid:1.3.0"
}
}
@@ -73,6 +73,10 @@ easygrid {
gridImpl = 'jqgrid' // the default grid implementation
+ // these are properties used by the jqgrid template
+ enableFilter = true
+ addNavGrid = true
+
//default export settings for various formats
export {
exportService = org.grails.plugin.easygrid.EasygridExportService
@@ -133,8 +137,6 @@ easygrid {
// jqgrid default properties
// check the jqgrid documentation
jqgrid {
- enableFilter = true
- addNavGrid = true
// width = '"100%"'
// height = 120
// number of rows to display by default
@@ -58,7 +58,6 @@ class OverviewController {
}
}
-
visitsGrid {
dataSourceType 'gorm'
domainClass Visit
@@ -18,40 +18,40 @@ Click on any owner , to see the pets in the grid below. And click on a pet to se
<td>
<grid:grid name="petsGrid" masterGrid="ownersGrid" childParamName="ownerId" jqgrid.width='290'
jqgrid.caption='"Pets"' addFunction="addPet" />
- <grid:exportButton name="petsGrid"/>
+ <grid:exportButton name="petsGrid" formats="['excel','csv']"/>
</td>
<td>&nbsp;</td>
<td>
<grid:grid name="visitsGrid" masterGrid="petsGrid" childParamName="petId" jqgrid.width='330'
jqgrid.caption='"Visits"' addFunction="addVisit" />
- <grid:exportButton name="visitsGrid"/>
+ <grid:exportButton name="visitsGrid" formats="['excel','csv']"/>
</td>
</tr>
</table>
</body>
<r:script>
+
function addPet(){
- var lnk = "${g.createLink(controller: 'pet',action: 'add')}";
- var owner = jQuery('#ownersGrid_table').jqGrid('getGridParam', 'selrow');
- if(jQuery.isEmptyObject(owner)){
- alert("You have to select an owner first");
- return;
- }
- lnk+="?owner.id="+owner;
- document.location = lnk;
+ addElement("${g.createLink(controller: 'pet',action: 'add')}", 'ownersGrid','owner.id', 'owner');
}
+
function addVisit(){
- var lnk = "${g.createLink(controller: 'pet',action: 'addVisit')}";
- var pet = jQuery('#petsGrid_table').jqGrid('getGridParam', 'selrow');
- if(jQuery.isEmptyObject(pet)){
- alert("You have to select a pet first");
+ addElement("${g.createLink(controller: 'pet',action: 'addVisit')}", 'petsGrid', 'id', 'pet');
+ }
+
+ function addElement(lnk, gridId,param, master){
+ var elem = jQuery('#'+gridId+'_table').jqGrid('getGridParam', 'selrow');
+ console.log(elem);
+ if(jQuery.isEmptyObject(elem)){
+ alert("You have to select a '+master+' first");
return;
}
- lnk+="?id="+pet;
- document.location = lnk;
+ document.location = lnk+"?"+param+"="+elem;;
+
}
+
function customShowFormat(cellvalue, options, rowObject) {
return "<a href='${g.createLink(controller: "owner", action: "show")}/" + cellvalue + "'>" + cellvalue + "</a> ";
}
@@ -42,8 +42,8 @@
<br/><span class="errors"><g:fieldError bean="${visit}" field="vet" /></span>
</th>
<td>
- <grid:selection id="vet" title="Select the vet" gridName="vetsGrid" controller="overview" name="visit.vet.id" value="${visit?.vet?.id}"/>
- %{--<g:select name="visit.vet.id" from="${org.grails.samples.Vet.all}" value="${visit?.vet?.id}" optionKey="id" optionValue="lastName" />--}%
+ <grid:selection id="vet" name="visit.vet.id" value="${visit?.vet?.id}"
+ gridName="vetsGrid" controller="overview" title="Select the vet" width="650" height="280"/>
</td>
<tr/>
<tr>
@@ -21,10 +21,10 @@
<tr>
<g:each in="${gridConfig.columns}" var="col">
<g:if test="${col?.classic?.sortable}">
- <g:sortableColumn property="${col.property}" title="${message(code: col.label, default: col.label)}" />
+ <g:sortableColumn property="${col.property}" title="${g.message(code: col.label, default: col.label)}" />
</g:if>
<g:else>
- <th >${message(code: col.label, default: col.label)}</th>
+ <th >${g.message(code: col.label, default: col.label)}</th>
</g:else>
</g:each>
</tr>
@@ -1,11 +1,15 @@
<script type="text/javascript">jQuery(function () {
- %{--todo - move some hardcodings to the config --}%
var oTable = $('#${attrs.id}_datatable').dataTable({
- bFilter:true,
- "bStateSave":false,
- 'sPaginationType':'full_numbers',
- "fnInitComplete":function () {
+
+ <g:each in="${gridConfig.dataTables}" var="property">
+ "${property.key}":${property.value},
+ </g:each>
+
+ bFilter: true,
+ "bStateSave": false,
+ 'sPaginationType': 'full_numbers',
+ "fnInitComplete": function () {
//hack - removes the filter div
$('#${attrs.id}_datatable_filter').remove();
var oSettings = $('#${attrs.id}_datatable').dataTable().fnSettings();
@@ -16,15 +20,32 @@
$("tfoot input")[i].className = "";
}
}
+ <g:if test="${gridConfig.fixedColumns == 'true'}">
+ new FixedColumns(oTable, {
+ "iLeftColumns": ${gridConfig.noFixedColumns}
+// "iLeftWidth": 350
+ });
+ </g:if>
+
+ },
+ "fnRowCallback": function (nRow, aData, iDisplayIndex, iDisplayIndexFull) {
},
- "bSort":true,
- "bProcessing":true,
- "bServerSide":true,
- "sAjaxSource":"${g.createLink(action: "${gridConfig.id}Rows")}",
- "aoColumns":[
+ "bSort": true,
+ "bProcessing": true,
+ "bServerSide": true,
+ "sAjaxSource": "${g.createLink(action: "${gridConfig.id}Rows")}",
+ "aoColumns": [
<g:each in="${gridConfig.columns}" var="col" status="idx">
- { "sName":"${col.name}", "bSortable":true } <g:if test="${idx < gridConfig.columns.size() - 1}">,
- </g:if>
+ { "sName": "${col.name}",
+ "bSearchable": ${col.enableFilter},
+ "bSortable": ${col.sortable},
+ <g:each in="${col.dataTables}" var="property">
+ "${property.key}":${property.value},
+ </g:each>
+ "bVisible": true
+ %{--"sWidth": "${col.dataTables.sWidth}",--}%
+ %{--"sClass": "${col.dataTables.sClass}"--}%
+ } <g:if test="${idx < gridConfig.columns.size() - 1}">,</g:if>
</g:each>
]
@@ -66,7 +87,7 @@
<thead>
<tr>
<g:each in="${gridConfig.columns}" var="col">
- <th %{--width="${col.datatable.width}"--}%>${message(code: col.label, default: col.label)}</th>
+ <th>${g.message(code: col.label, default: col.label)}</th>
</g:each>
</tr>
</thead>
@@ -78,8 +99,8 @@
<tfoot>
<tr>
<g:each in="${gridConfig.columns}" var="col">
- <td>%{--width="${col.datatable.width}">--}%
- <g:if test="${col.enableFilter}">
+ <td>
+ <g:if test="${(gridConfig.fixedColumns != 'true') &&gridConfig.enableFilter && col.enableFilter}">
<input type="text" name="search_${col.name}" class="search_init" size="10"/>
</g:if>
<g:else>
@@ -46,8 +46,8 @@
</g:if>
});
- <g:if test="${gridConfig.jqgrid.addNavGrid}">
- jQuery('#${attrs.id}_table').jqGrid('navGrid','#${attrs.id}Pager',
+ <g:if test="${gridConfig.addNavGrid}">
+ jQuery('#${attrs.id}_table').jqGrid('navGrid','#${attrs.id}Pager',
{
add: false,
edit:false,
@@ -56,27 +56,27 @@
refresh: true
})
<g:if test="${gridConfig.addUrl}">
- .jqGrid('navButtonAdd','#${attrs.id}Pager',{caption:"", buttonicon:"ui-icon-plus", onClickButton:function(){
+ .jqGrid('navButtonAdd','#${attrs.id}Pager',{caption:"", buttonicon:"ui-icon-plus", onClickButton:function(){
document.location = '${gridConfig.addUrl}';
}});
</g:if>
<g:if test="${gridConfig.addFunction}">
- .jqGrid('navButtonAdd','#${attrs.id}Pager',{caption:"", buttonicon:"ui-icon-plus", onClickButton:${gridConfig.addFunction}});
+ .jqGrid('navButtonAdd','#${attrs.id}Pager',{caption:"", buttonicon:"ui-icon-plus", onClickButton:${gridConfig.addFunction}});
</g:if>
</g:if>
- <g:if test="${gridConfig.jqgrid.enableFilter}">
- jQuery('#${attrs.id}_table').jqGrid('filterToolbar',
+ <g:if test="${gridConfig.enableFilter}">
+ jQuery('#${attrs.id}_table').jqGrid('filterToolbar',
{
autosearch: true,
searchOnEnter: true
});
</g:if>
- %{--test if the current grid has a master grid --}%
+%{--test if the current grid has a master grid --}%
<g:if test="${gridConfig.masterGrid}">
- %{--set the on select row of the master grid--}%
+ %{--set the on select row of the master grid--}%
jQuery('#${gridConfig.masterGrid}_table').setGridParam(
{
"onSelectRow" : function(rowid,status,e){
@@ -17,12 +17,16 @@
</g:if>
<g:else>
- options = {};
- query.abort();
- var tableQueryWrapper = new TableQueryWrapper(query, container, options);
- tableQueryWrapper.sendAndDraw();
+ options = {
+ <g:each in="${gridConfig.visualization}" var="property" status="idx">
+ <g:if test="${idx>0}">,</g:if> "${property.key}":${property.value}
+ </g:each>
+ };
+ query.abort();
+ var tableQueryWrapper = new TableQueryWrapper(query, container, options);
+ tableQueryWrapper.sendAndDraw();
- </g:else>
+ </g:else>
}
@@ -47,7 +51,7 @@
*/
- function rewriteDatasource(form) {
+ function rewriteDatasource${attrs.id}(form) {
var ser = jQuery(form).serialize();
console.log(ser);
dataSourceUrl = baseDataSourceUrl + "?" + ser;
@@ -58,13 +62,13 @@
</script>
+%{--create a very basic search form--}%
<div id="${attrs.id}_FilterDiv">
- %{--<g:formRemote name="${attrs.id}_FilterForm" onSuccess="_reloadGrid(data,textStatus)" url='[action:"${gridConfig.id}Rows"]'>--}%
- <form name="${attrs.id}_FilterForm" onsubmit="return rewriteDatasource(this)" action="${gridConfig.id}Rows">
+ <form name="${attrs.id}_FilterForm" onsubmit="return rewriteDatasource${attrs.id}(this)" action="${gridConfig.id}Rows">
<fieldset class="form">
<g:hiddenField name="_filter" value="true"/>
<g:findAll in="${gridConfig.columns}" expr="${it.enableFilter}">
- <div>
+ <div class="fieldcontain ">
<label for="${it.name}">
<g:message code="${it.label}" default="${it.label}"/>
</label>

0 comments on commit ee1900b

Please sign in to comment.