Skip to content

Instantly share code, notes, and snippets.

@krams915
krams915 / gist:1218381
Created September 15, 2011 02:32
Event Table (jQGrid version) - jsonReader
jsonReader : {
root: "rows",
page: "page",
total: "total",
records: "records",
repeatitems: false,
cell: "cell",
id: "id"
}
@krams915
krams915 / JqgridTableDto.java
Created September 15, 2011 02:34
JqgridTableDto
package org.krams.tutorial.dto;
import java.util.List;
/**
* A POJO representing a jQgrid's jsonReader property.
* This is mainly used as a DTO for the presentation layer.
*
* @see <a href="http://www.trirand.com/jqgridwiki/doku.php?id=wiki:retrieving_data#json_data">JSON Data</a>
*
@krams915
krams915 / JqgridEventController.java
Created September 15, 2011 02:40
JqgridEventController
package org.krams.tutorial.controller;
import java.util.List;
import org.krams.tutorial.domain.Event;
import org.krams.tutorial.dto.JqgridTableDto;
import org.krams.tutorial.dto.ResponseDto;
import org.krams.tutorial.service.IEventService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
@krams915
krams915 / event-page.jsp
Created September 15, 2011 03:45
Event Table (DataTables version)
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://www.springframework.org/tags" prefix="spring" %>
<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form" %>
<c:url value="/" var="rootUrl"/>
<c:url value="/resources" var="resourcesUrl"/>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
@krams915
krams915 / event-page(snippet).jsp
Created September 15, 2011 03:50
Event Table (DataTables version) - imports
<!-- CSS Imports-->
<link rel="stylesheet" type="text/css" media="screen" href="${resourcesUrl}/css/jquery/dark-hive/jquery-ui-1.8.6.custom.css"/>
<link rel="stylesheet" type="text/css" media="screen" href="${resourcesUrl}/css/datatables/custom.css"/>
<link rel="stylesheet" type="text/css" media="screen" href="${resourcesUrl}/css/main/main.css"/>
<!-- JS Imports -->
<script type="text/javascript" src="${resourcesUrl}/js/jquery/jquery-1.5.2.min.js"></script>
<script type="text/javascript" src="${resourcesUrl}/js/jquery/jquery-ui-1.8.12.custom.min.js"></script>
<script type="text/javascript" src="${resourcesUrl}/js/datejs/date.js"></script>
<script type="text/javascript" src="${resourcesUrl}/js/datatables/jquery.dataTables.min.js"></script>
@krams915
krams915 / event-page(snippet).jsp
Created September 15, 2011 03:53
Event Table (DataTables version) - table
<h3 class="title">Events - DataTables Version</h3>
<table id='eventTable'>
<thead>
<tr>
<th></th>
<th>Id</th>
<th>Name</th>
<th>Description</th>
<th>Participants</th>
<th>Date</th>
@krams915
krams915 / event-page(snippet).jsp
Created September 15, 2011 03:54
Event Table (DataTables version) - dialogs
<jsp:include page="/WEB-INF/jsp/dialogs/addDialog.jsp"/>
<jsp:include page="/WEB-INF/jsp/dialogs/editDialog.jsp"/>
<jsp:include page="/WEB-INF/jsp/dialogs/deleteDialog.jsp"/>
<jsp:include page="/WEB-INF/jsp/dialogs/genericDialog.jsp"/>
@krams915
krams915 / event-page(snippet).jsp
Created September 15, 2011 03:55
Event Table (DataTables version) - Buttonize links
$(function() {
// Convert links to buttons
$('#addLink, #editLink, #deleteLink').button();
...
...
});
@krams915
krams915 / event-page(snippet).jsp
Created September 15, 2011 03:57
Event Table (DataTables version) - Attach functions to links
$(function() {
...
...
// Assign a function to addLink
// Displays a dialog form for adding a new record
$("#addLink").click(function() {
// Show the dialog
$( "#addDialog" ).dialog({
modal: true,
@krams915
krams915 / event-page(snippet).jsp
Created September 15, 2011 03:58
Event Table (DataTables version) - Init DataTables
$(function() {
...
...
// Retrieve all records for the first time
// Converts table to DataTable as well
$.getRecords('#eventTable', '${rootUrl}event/getall',
['id', 'name', 'description', 'participants', 'date'],
function() {
$('#eventTable').dataTable( {