Simone
05/17/2023, 5:06 PM{"draw": <cfoutput>#val(draw)#</cfoutput>,
"recordsTotal": <cfoutput>#recordsTotal#</cfoutput>,
"recordsFiltered": <cfoutput>#qFiltered.recordCount#</cfoutput>,
"data": [
<cfif qFiltered.recordcount gt 0>
<cfoutput query="qFiltered" startrow="#val(start+1)#" maxrows="#val(length)#">
<cfif currentRow gt (start+1)>,</cfif>
#Replace(SerializeJSON(qFiltered,'struct'),'\','','all')#,
</cfoutput>
<cfelse>
""
</cfif>
]
}
someehow the code is ending in invalid nested data, not sure what i am doing wrong hereMyka Forrest
05/17/2023, 5:12 PMserializeJSON()
to convert to JSON.Adam Cameron
Evil Ware
05/17/2023, 6:09 PMMatt Jones
05/17/2023, 6:20 PMSimone
05/17/2023, 7:22 PMSimone
05/17/2023, 7:22 PMSimone
05/17/2023, 7:23 PMSimone
05/17/2023, 7:23 PMMyka Forrest
05/17/2023, 7:23 PMstructKeyExists()
Myka Forrest
05/17/2023, 7:24 PMorder
a struct?Myka Forrest
05/17/2023, 7:24 PMAdam Cameron
isDefined
answers your question: https://helpx.adobe.com/coldfusion/cfml-reference/coldfusion-functions/functions-in-k/isdefined.htmlMatt Jones
05/17/2023, 7:42 PMcolumns = ["your", "column", "names", "in", "order"];
order_clause = "";
// parse the stuff datatables passed to us
for ( sortColumn=0; sortColumn lt arrayLen(columns); sortColumn++ ) {
if ( structKeyExists(form, "order[#sortColumn#][column]") && isValid("integer", form["order[#sortColumn#][column]"]) ) {
order_clause = listAppend(order_clause, columns[ form["order[#sortColumn#][column]"]+1 ] );
if ( structKeyExists(form, "order[#sortColumn#][dir]") && listFindNoCase("asc,desc", form["order[#sortColumn#][dir]"]) ) {
order_clause = listAppend(order_clause, form["order[#sortColumn#][dir]"], " " )
}
}
}
if( !len( order_clause ) ){
order_clause = columns[1] & " asc";
}
order_clause = " order by " & order_clause;
Matt Jones
05/17/2023, 7:45 PMMatt Jones
05/17/2023, 7:46 PMMatt Jones
05/17/2023, 7:47 PMMatt Jones
05/17/2023, 7:47 PMMatt Jones
05/17/2023, 7:57 PMSimone
05/18/2023, 2:32 AMmbh
05/18/2023, 10:36 AM<cfscript>
// Get Your Data from CFQuery
// I am using a memory query in this example but it can me replaced with a real query
// The memory query was created from a JSON response that when deserialized returns an array of structured
// This example is just doing the opposite logic
// Get The DataSet
dataSet = QueryExecute(
"SELECT * FROM RandomMemoryQuery",
{
// Only set for
DBType = "query",
// Change the return type from query to array
returnType = "array"
}
)
// Data Manipulation Logic. For example add a unique key value pair using CreateUUID()
// Serialize the data
ResfulQueryData = SerializeJSON( dataSet )
</cfscript>
<cfquery name="dataSet" DBType="query" returnType="array">
SELECT * FROM RandomMemoryQuery
</cfquery>
<cfoutput>
<!--- Data Manipulation Logic --->
<cfset ResfulQueryData = SerializeJSON( dataSet ) />
</cfoutput>
Simone
05/18/2023, 11:32 AMMatt Jones
05/18/2023, 2:10 PMSimone
05/18/2023, 4:31 PMSimone
05/18/2023, 4:31 PMSimone
05/18/2023, 4:32 PMEvil Ware
05/18/2023, 4:42 PMEvil Ware
05/18/2023, 4:44 PMmbh
05/18/2023, 4:46 PMSimone
05/18/2023, 4:51 PMEvil Ware
05/18/2023, 4:54 PMSimone
05/18/2023, 4:54 PMmbh
05/18/2023, 4:55 PMmbh
05/18/2023, 4:55 PMEvil Ware
05/18/2023, 4:56 PMmbh
05/18/2023, 4:56 PMmbh
05/18/2023, 4:57 PMEvil Ware
05/18/2023, 4:57 PMSimone
05/18/2023, 4:58 PMSimone
05/18/2023, 4:58 PMEvil Ware
05/18/2023, 4:58 PMSimone
05/18/2023, 5:03 PMMyka Forrest
05/18/2023, 5:07 PM<cfparam name="form.length" DEFAULT="10" TYPE="integer" />
I dont' see anyplace where you alter this, but seems like it might be related?Simone
05/18/2023, 5:09 PMSimone
05/18/2023, 5:10 PM<cfset qFiltered = getUsers(form.*SEARCH*,1,*LENGTH*,form.searchColumn,form.searchOrder)>
Myka Forrest
05/18/2023, 5:10 PMSimone
05/18/2023, 5:10 PMMyka Forrest
05/18/2023, 5:10 PMform.length
?Simone
05/18/2023, 5:17 PMMyka Forrest
05/18/2023, 5:18 PMform.length
is passed as @pageSize
, right?Myka Forrest
05/18/2023, 5:19 PMSimone
05/18/2023, 5:20 PMMyka Forrest
05/18/2023, 5:21 PMEvil Ware
05/18/2023, 5:22 PMSimone
05/18/2023, 5:29 PMMatt Jones
05/18/2023, 5:33 PMMatt Jones
05/18/2023, 5:35 PMEvil Ware
05/18/2023, 5:37 PMSimone
05/18/2023, 5:39 PMEvil Ware
05/18/2023, 5:41 PMMatt Jones
05/18/2023, 5:43 PMMyka Forrest
05/18/2023, 5:43 PMpageSize
parameter. Nowhere in the code that you have shared does that value, stemming from form.length
, ever change.Matt Jones
05/18/2023, 5:43 PMEvil Ware
05/18/2023, 5:46 PMMatt Jones
05/18/2023, 5:50 PMEvil Ware
05/18/2023, 5:51 PMMatt Jones
05/18/2023, 5:58 PMEvil Ware
05/18/2023, 6:06 PMMatt Jones
05/18/2023, 6:12 PMEvil Ware
05/18/2023, 6:15 PMgsr
05/18/2023, 7:12 PMMatt Jones
05/18/2023, 7:48 PMSimone
05/19/2023, 12:51 AMSimone
05/19/2023, 12:52 AMMyka Forrest
05/19/2023, 12:53 AMform. Length
, which is what is being passed as pageSize
to your sp, will always be 10.Simone
05/19/2023, 12:54 AMSimone
05/19/2023, 12:54 AMMyka Forrest
05/19/2023, 12:54 AMSimone
05/19/2023, 12:55 AMSimone
05/19/2023, 12:59 AMMyka Forrest
05/19/2023, 1:09 AMMatt Jones
05/19/2023, 12:51 PMSimone
05/25/2023, 4:44 PMSimone
05/25/2023, 4:46 PM[
"<a href=activity.cfm?id= 06 target=_blank>Activities</a>",
"01/09/2016 01:00:00 AM",
null,
"<mailto:mm@noreply.com|mm@noreply.com>",
"07/02/2020 01:49:06 PM",
"07/02/2020 01:49:06 PM",
"<a href=o.cfm?parentID= 30006>1593</a>",
"01/09/2016 01:00:00 AM",
"<a href=od.cfm?id=3000 target=_blank>Details</a>",
null,
"01/09/2016 12:00:00 AM",
"300053",
"Collaboration",
null,
6956
],
error i am getting is:
DataTables warning: table id=DataTables_Table_0 - Requested unknown parameter 'activities' for row 0, column 0. For more information about this error, please see <http://datatables.net/tn/4>
Simone
05/25/2023, 4:47 PM<cfset ret["data"] = deserializeJSON(serializeJSON(users)).DATA>
Myka Forrest
05/25/2023, 4:48 PMMyka Forrest
05/25/2023, 4:52 PMSimone
05/25/2023, 4:54 PMSimone
05/25/2023, 4:55 PM{
"recordsFiltered": 6956,
"recordsTotal": 6956,
"draw": "1",
"data": [
[
"<a href=activity.cfm?id= 06 target=_blank>Activities</a>",
"01/09/2016 01:00:00 AM",
null,
"<mailto:mm@noreply.com|mm@noreply.com>",
"07/02/2020 01:49:06 PM",
"07/02/2020 01:49:06 PM",
"<a href=o.cfm?parentID= 30006>1593</a>",
"01/09/2016 01:00:00 AM",
"<a href=od.cfm?id=3000 target=_blank>Details</a>",
null,
"01/09/2016 12:00:00 AM",
"300053",
"Collaboration",
null,
6956
],
[
"<a href=activity.cfm?id= 06 target=_blank>Activities</a>",
"01/09/2016 01:00:00 AM",
null,
"<mailto:mm@noreply.com|mm@noreply.com>",
"07/02/2020 01:49:06 PM",
"07/02/2020 01:49:06 PM",
"<a href=o.cfm?parentID= 30006>1593</a>",
"01/09/2016 01:00:00 AM",
"<a href=od.cfm?id=3000 target=_blank>Details</a>",
null,
"01/09/2016 12:00:00 AM",
"300053",
"Collaboration",
null,
6956
]
]
}
Myka Forrest
05/25/2023, 5:00 PMparameter 'activities'
?Simone
05/26/2023, 7:20 PM