coldfusion - jQuery Datatables/CF variable issue -
i using jquery datatables , coldfusion along sql database. trying figure out way have status field show processing
if there no date date_complete
, completed
if there date in date_complete
. doing on html cf side if statement.
but since posting completed
or processing
in column when try call in js date not providing date providing terminology now.
on picture below see date complete: completed
should show date.
any appreciated.
html
<table id="processing" class="table table-hover"> <thead> <th></th> <th><b>item id</b></th> <th style="display:none;"><b>dealer id</b></th> <th style="display:none;"><b>date received</b></th> <th style="display:none;"><b>op id</b></th> <th><b>due date</b></th> <th><b>status</b></th> <th style="display:none;"><b>late</b></th> <th style="display:none;"><b>closed by</b></th> <th style="display:none;"><b>rmks</b></th> <th style="display:none;"><b>processing location</b></th> <th><b>qty</b></th> </thead> <tbody> <cfoutput query="processtable"> <tr> <td class="details-control"></td> <td class="lalign">#id#</td> <td style="display:none;">#processtable.name#</td> <td style="display:none;">#dateformat(processtable.date_received, 'mm/dd/yyyy')#</td> <td style="display:none;">#op_id#</td> <td>#dateformat(processtable.date_due, 'mm/dd/yyyy')#</td> <cfif #date_complete# eq ""> <td>processing</td> <cfelse> <td>completed</td> </cfif> <td style="display:none;">#completed_late#</td> <td style="display:none;">#closed_by#</td> <td style="display:none;">#rmks#</td> <td style="display:none;">#processing_location#</td> <td class="calign">#item_count#</td> </tr> </cfoutput> </tbody> </table>
js
function format ( d ) { return 'item id: '+d.id+'<br>'+ 'dealer: '+d.dealerid+'<br>'+ 'date received: '+d.date_received+'<br>'+ 'checked in: '+d.op_id+'<br>'+ 'date due: '+d.date_due+'<br>'+ 'date complete: '+d.date_complete+'<br>'+ 'completed late: '+d.completed_late+'<br>'+ 'completed by: '+d.closed_by+'<br>'+ 'remarks: '+d.rmks+'<br>'+ 'location: '+d.processing_location+'<br>'+ 'item count: '+d.item_count+'<br>'; } // setup page once has loaded. $(document).ready(function() { var otable = $('#processing').datatable( { "columns": [ { "class": "details-control", "orderable": false, "data": null, "defaultcontent": "" }, { "data": "id" }, { "data": "dealerid" }, { "data": "date_received" }, { "data": "op_id" }, { "data": "date_due" }, { "data": "date_complete" }, { "data": "completed_late" }, { "data": "closed_by" }, { "data": "rmks" }, { "data": "processing_location" }, { "data": "item_count" } ], "order": [[1, 'asc']], "columndefs": [ { "targets": [0,2,3,4,5,6,7,8,9,10,11], "searchable": false } ], "sdom": '<"row view-filter"<"col-sm-12"<"pull-left"l><"pull-right"f><"clearfix">>>t<"row view-pager"<"col-sm-12"<"text-center"ip>>>', select: { style: 'single' }, scrolly: 250, deferrender: true, scroller: true, /*"alengthmenu": [[25, 50, 75, -1], [25, 50, 75, "all"]], "idisplaylength": 25,*/ "olanguage": { "slengthmenu": "_menu_ <label for='processing_length'><strong>records per page</strong></label>", "opaginate": { "sprevious": "«", "snext": "»", } } });
cfc
<cffunction name="displaytable" access="public" returntype="query"> <cfset var processtable = ''> <cfquery name="processtable"> select * dbo.dealer_track_work, dbo.dealer_track_dealers dbo.dealer_track_work.dealerid = dbo.dealer_track_dealers.id </cfquery> <cfreturn processtable> </cffunction>
replace html code:
<cfif #date_complete# eq ""> <td>processing</td> <cfelse> <td>completed</td> </cfif>
with
<td>#dateformat(date_complete,"mm/dd/yyyy")#</td>
replace javascript code
{ "data": "date_complete" },
with
{ "data": "date_complete", "render": function(data, type, full, meta){ return ((data) ? "completed" : "processing"); } },
Comments
Post a Comment