jQWidgets Forums

jQuery UI Widgets Forums Grid jqxGrid, json & ColdFusion

This topic contains 4 replies, has 1 voice, and was last updated by  Larryp88 12 years, 1 month ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
  • jqxGrid, json & ColdFusion #21223

    Larryp88
    Participant

    I’m hoping for a little help getting data to appear in my grid using a CFC. When I test the page the grid shows “No Data to Display”. I started with the demo file rowselection and took out some of the other features in that template. I don’t know if the issue is in my CFC or in the script code on the html page.

    I’m running CF9 and jqWidgets 2.8.3

    Here’s the CFC:

    <cfcomponent>
    <cffunction name="gCases" access="remote" returntype="any" returnformat="plain" output="no">
    <!---<cfargument name="myArgument" type="string" required="yes">--->
    <cfquery name="getC" datasource="jasman">
    SELECT TOP 500 SeqID, FullCaseNo, DefName, ISNULL(DOB,'1/1/1907') AS DOB, ISNULL(Race,'U') AS Race, ISNULL(Gender,'U') AS Gender, StatusDesc, ISNULL(JudgeLastName,'None')AS JudgeLastName FROM vCases ORDER BY SeqID DESC
    </cfquery>
    <cfset rData = ArrayNew(1)>
    <cfloop query="myResult">
    <cfset row = StructNew()>
    <cfset row["SeqID"] = getC.SeqID>
    <cfset row["FullCaseNo"] = getC.FullCaseNo>
    <cfset row["DefName"] = getC.DefName>
    <cfset row["DOB"] = DateFormat(getC.DOB,"mm/dd/yyyy")>
    <cfset row["Race"] = getC.Race>
    <cfset row["Gender"] = getC.Gender>
    <cfset row["StatusDesc"] = getC.StatusDesc>
    <cfset row["JudgeLastName"] = getC.JudgeLastName>
    <cfset data[getC.RecordCount] = row>
    </cfloop>
    <cfset theOutput = serializeJSON(data)>
    <cfreturn theOutput>
    </cffunction>
    </cfcomponent>

    And HTML:

    <!DOCTYPE html>
    <html lang="en">
    <head>
    <title id='Description'>This example shows how to use the Grid Row Selection API.
    </title>
    <link rel="stylesheet" href="jqwidgets/styles/jqx.base.css" type="text/css" />
    <link rel="stylesheet" href="jqwidgets/styles/jqx.black.css" type="text/css" />
    <script type="text/javascript" src="scripts/jquery-1.8.3.min.js"></script><!-- this is the most stable version and works with Chrome and Firefox -->
    <script type="text/javascript" src="jqwidgets/jqx-all.js"></script>
    <script type="text/javascript">
    $(document).ready(function () {
    var theme = 'black';
    var source =
    {
    datatype: "json",
    datafields:
    [
    { name: 'SeqID', type: 'string' },
    { name: 'FullCaseNo', type: 'string' },
    { name: 'DefName', type: 'string' },
    { name: 'DOB', type: 'string' },
    { name: 'Race', type: 'string' },
    { name: 'Gender', type: 'string' },
    { name: 'StatusDesc', type: 'string' },
    { name: 'JudgeLastName', type: 'string' }
    ],
    url: 'getCases.cfc?method=gCases'
    };
    var dataAdapter = new $.jqx.dataAdapter(source);
    // initialize jqxGrid
    $("#jqxgrid").jqxGrid(
    {
    width: 750,
    height: 550,
    source: dataAdapter,
    // sortable: true,
    // pageable: true,
    theme: theme,
    columns: [
    { text: 'ID', datafield: 'SeqID', width: 50 },
    { text: 'Case Number', datafield: 'FullCaseNo', width: 120 },
    { text: 'Defendant', datafield: 'DefName', width: 200 },
    { text: 'DOB', datafield: 'DOB', width: 80 },
    { text: 'Race', datafield: 'Race', width: 50 },
    { text: 'Gender', datafield: 'Gender', width: 50 },
    { text: 'Status', datafield: 'StatusDesc', width: 70 },
    { text: 'Judge', datafield: 'JudgeLastName', width: 100 }
    ]
    });
    // select the first row.
    $("#jqxgrid").jqxGrid('selectrow', 0);
    });
    </script>
    </head>
    <body class='default'>
    <div id="jqxgrid">
    </div>
    <div style="clear: both; font-family: Verdana, Geneva, 'DejaVu Sans', sans-serif; font-size: 12px;">
    <span>Selection Log:</span>
    <div style="margin-top: 10px;">
    <span>Selected Row Index:</span> <span id="selectrowindex"></span>
    <br />
    <span>Unselected Row Index:</span> <span id="unselectrowindex"></span>
    </div>
    </div>
    </body>
    </html>
    jqxGrid, json & ColdFusion #21229

    Larryp88
    Participant

    Well, I found one problem in my CFC…I’m looping through a query that doesn’t exist! Regardless, I fixed that and still no go tho.

    jqxGrid, json & ColdFusion #21231

    Larryp88
    Participant

    I also fixed the “rdata” vs. “data” var name issue. Must sleep.

    jqxGrid, json & ColdFusion #21232

    Larryp88
    Participant

    I got it to work with 1 record instead of 500, so I’m close. Sorry to bother you. Love the widgets! Thanks!

    jqxGrid, json & ColdFusion #21233

    Larryp88
    Participant

    Got it. Fixed the “RecordCount” to “CurrentRow” in CFC, works great. FYI…
    So all of my problems were in the CFC due to silly mistakes. Great.

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.