-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.cfm
executable file
·90 lines (84 loc) · 2.93 KB
/
index.cfm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
<h1>CFWheels plugin for DataTables v0.1a</h1>
<h2>Christopher Jazinski</h2>
== Modified ==<br />
<a href="https://github.com/mhenke/DataTablesForWheels">https://github.com/mhenke/DataTablesForWheels</a><br />
<br />
== Requirements ==<br />
CFWheels [Tested 1.1.8]<br />
DataTables jQuery plugin (included)<br />
bootstrap style sheet (included)<br />
DataTables images (included)<br />
jQuery<br />
<br />
== Changes from Base==<br />
<ul>
<li>Pass in custom params
<ul>
<li>Requires modification of DataTables.cfc</li>
<li>Defaults are CRUD params added $dataTablesCRUDParams()</li>
</ul>
</li>
<li>Added bootstrap theme</li>
<li>Added bootstrap pagination</li>
<li>Added default CRUD links to table</li>
<li>Added Ability to make columns <b>NOT</b> sortable</li>
<li>Added Ability to show/hide footer columns</li>
</ul><br />
== Installation ==<br />
1) Place the DataTables-X.X.zip in your plugins folder<br />
2) Place assets in javascripts/images/stylesheets of cfWheels directory(s)<br />
3) Add this code to your /Controllers/Controller.cfc<br />
cfinclude template="/plugins/datatables/datatables.cfm" <br />
or cfscript<br />
include "../plugins/datatables/datatables.cfm";<br />
4) Reload your Wheels application.<br />
<h3>EXAMPLE</h3>
<h4>== VIEW FILE ==</h4>
<p>
styleSheetLinkTag(source='datatables/DT_bootstrapv2', head="true")<br />
javaScriptIncludeTag("datatables/DT_bootstrap")<br />
</p>
<p>
<span class="comment">// table name is your ACTION NAME appended with _table_id</span> <br />
getdatatablesHTML(myActionName,myColumnNames)
</p>
<h4>== Controller (for View) ==</h4>
<p>
In your Controller have a function called your ACTION NAME that returns a query.
</p>
<p>
<span class="comment">// my ACTION NAME for the datatables</span> <br />
private query function example() {
<div style="padding-left: 15px;">
var entries = model('entry').findAll(select='BODY,ID, TITLE')<br />
return entries;<br />
</div><br />
}
</p>
<p>In your Controller under the action that will run (this case demo)</p>
<p>
public any function demo() {
<div style="padding-left: 15px;">
myActionName = 'example';<br />
myColumnNames = ArrayNew(1);<br />
myColumnNames[1] = 'Body';<br />
myColumnNames[2] = 'ID';<br />
myColumnNames[3] = 'Title';<br />
<br />
<span class="comment">// pass in controller and ACTION NAME OR</span><br />
getdatatablesJS('datatables','example')<br />
<br />
<span class="comment">// pass in controller, action name, and sort order OR </span> <br />
getdatatablesJS('datatables','example','body desc, dateCreated desc')<br />
<br />
<span class="comment">// pass in controller, action name, sort order, array of user params or defaults ($dataTablesCrudParams()), and cols NOT sortable </span> <br />
getDatatablesJS('datatables', 'example', 'id asc', $dataTablesCrudParams(delete=false), [4,5])<br />
</div><br />
}
<br />
</p>
<style type="text/css">
.comment {
background-color: yellow;
}
</style>