11 Replies Latest reply on Mar 7, 2017 12:28 AM by BKBK

    CFGRID html with bind - not rendering, getting spinner

    Libby H Level 1

      Sorry to bother everyone again, but I am again needing assistance with converting my CFGRIDS from applets to html formats using CFC and binds.

      I have been testing the grids one step at a time -  first by just adding the format="html" and enclosing the CFGRID within a CFFORM.  Looks okay.  Then I created the cfc and moved the query, and created the bind.  Now I get the grid appearing without any data, and the spinner in the base of the grid.

       

      Here is my code: payment.cfc

      <cfcomponent>
          <cffunction name="getData" access="remote" output="false">
              <cfargument name="page">
              <cfargument name="pageSize">
              <cfargument name="gridsortcolumn">
              <cfargument name="gridsortdirection">

              <cfquery name="payment_all" datasource="Treasury">
                SELECT Payment_Type, Payment_Desc
                  FROM paytype
      <!---             <cfif gridsortcolumn# NEQ "" or gridsortdirection NEQ ""> 
                      order by #gridsortcolumn# #gridsortdirection#
                  </cfif> --->
           </cfquery>
              <cfreturn QueryConvertForGrid(payment_all, page, pageSize)>
          </cffunction>
      </cfcomponent>

       

      My grid: paymentgrid.cfm

      <cfform>

             <cfgrid format="html" name="paymentcodegrid"  height="254" width="315"

                      pagesize=10 selectmode="row" striperows="yes" font="Arial" fontsize="10"

                      bind="cfc:payment.getData({cfgridpage},{cfgridpagesize},{cfgridsortcolumn},{cfgridsortdir ection})" >

                      <cfgridcolumn name="Payment_Type" header="Payment Code" width="95" />

                      <cfgridcolumn name="Payment_Desc" header="Payment Description" width="200" />

              </cfgrid>

          </cfform>

       

      Both my cfgrid and my cfc are textbook copies from the ColdFusion manual's. My results are all but textbook. First of all, the page with the CFGRID renders the grid empty, with the spinner in the bottom of the grid next to the >| button for the last page. No error is returned in the application.log or the exception.log.

      Also, I have taken to commenting out the

      <cfif gridsortcolumn# NEQ "" or gridsortdirection NEQ ""> 

                      order by #gridsortcolumn# #gridsortdirection#

        </cfif>

      statement from my query.  When I leave it in as is, I get a SQL Server error - "Error Executing Database Query.[Macromedia][SQLServer JDBC Driver][SQLServer]Incorrect syntax near the keyword 'ASC'. The specific sequence of files included or processed is: E:\inetpub\WWWROOT\Treasury\payment.cfc, line: 12 "

      I have tried putting a default into the cfargument statements push the values, didn't work.  I even commented out the statement and just put in a regular 'order by' statement, and still get the same results.

       

      So I've tried this both in CF 9,0,2,282541  and on CF10, so I am really stumped.  I've searched the internet and spent days with folks that have spent years working on ColdFusion with no luck.

      Windows 2008, SQL Server 2008R2.

      Any ideas would be greatly appreciated.

       

      Thanks.  Libby H.

        • 1. Re: CFGRID html with bind - not rendering, getting spinner
          haxtbh Level 4

          Is this correct or a typo when you wrote it on here?

           

          <cfif gridsortcolumn# NEQ "" or gridsortdirection NEQ "">

           

          You have a rogue # in there that shouldnt be there and could be causing issues.

           

          This also cannot be an OR as it means it will work if either one has a value. In the case of the SQL error, the gridsortdirection as the value and gridsortcolumn doesn't, which means the SQL malforms. It should really be an AND to make sure they both pass to allow the order by

           

          If you still get the error when commenting out he SQL part, then I would suggest putting a cftry / cfcatch in your component function to output any errors that are happening. You could also make sure your cfarguments all have defaults so that there is guaranteed to be values passed further in the function.

           

          Finally you have the function QueryConvertForGrid, are you sure the values being passed here are correct and there is no error with this function?

          • 2. Re: CFGRID html with bind - not rendering, getting spinner
            Libby H Level 1

            Thank you for catching my typo (the # and the OR).  I have removed the # and replaced the OR with an AND - so that fixed that problem.

            But I still have the bigger issue of the CFGRID not rendering and the spinner.  I took your advise and placed a cftry/cfcatch as such:

            cfcomponent>
                <cffunction name="getData" access="remote" output="false">
                    <cfargument name="page">
                    <cfargument name="pageSize">
                    <cfargument name="gridsortcolumn">
                    <cfargument name="gridsortdirection">
            <cftry>
                    <cfquery name="payment_all" datasource="Treasury">
                      SELECT Payment_Type, Payment_Desc
                        FROM paytype
                         <cfif gridsortcolumn NEQ "" and gridsortdirection NEQ ""> 
                            order by #gridsortcolumn# #gridsortdirection#
                        </cfif>
                 </cfquery>
                    <cfreturn QueryConvertForGrid(payment_all, page, pageSize)>
            <cfcatch type="any">
            Whoops! There was an internal error.
            <br>Please contact the Administrator! <p>
            Here's info on the error:
            <cfoutput>
            <br>
            <b>Type</b>: #CFCATCH.Type#<br>
            <b>Message</b>: #CFCATCH.Message#<br>
            <b>Detail</b>: #CFCATCH.Detail#<br>

            <b>Fuseaction</b>: "#attributes.fuseaction#"<br>
            <b>Fuseaction2</b>: "#attributes.fuseaction2#"<br>

            </cfoutput>

            </cfcatch>
            </cftry>
                </cffunction>
            </cfcomponent>

             

            I still receive the same results - the CFGRID appears empty, with the spinner in the bottom of the grid next to the >| button for the last page. No error is returned in the application.log or the exception.log.  No result from the cftry/cfcatch.

            • 3. Re: CFGRID html with bind - not rendering, getting spinner
              haxtbh Level 4

              Outputting the error like that wont produce the result as you will not see the error output anywhere.

               

              The quickest thing to do is something like this

               

              <cfcatch type="any">
                   <cflog text="#CFCATCH.Type# - #CFCATCH.Message# - #CFCATCH.Detail# - #CFCATCH.TagContext[1].line#  - #CFCATCH.TagContext[1].Template#">
              </cfcatch>
              

               

              This will just log an error to the application.log.

              • 4. Re: CFGRID html with bind - not rendering, getting spinner
                WolfShade Level 4

                Or, along the lines of what haxtbh suggested, you can CFMAIL a dump of the cfcatch object to yourself.

                 

                Make sure you set type="html" so you can read it.

                 

                V/r,

                 

                ^_^

                • 5. Re: CFGRID html with bind - not rendering, getting spinner
                  Libby H Level 1

                  I've changed the CFCATCH as you recommended -

                  <cfcomponent>

                      <cffunction name="getData" access="remote" output="false">

                          <cfargument name="page">

                          <cfargument name="pageSize">

                          <cfargument name="gridsortcolumn">

                          <cfargument name="gridsortdirection">

                  <cftry>

                          <cfquery name="payment_all" datasource="Treasury">

                            SELECT Payment_Type, Payment_Desc

                              FROM paytype

                     <cfif gridsortcolumn NEQ "" and gridsortdirection NEQ ""> 

                                  order by #gridsortcolumn# #gridsortdirection#

                              </cfif>

                       </cfquery>

                          <cfreturn QueryConvertForGrid(payment_all, page, pageSize)>

                  <cfcatch type="any">

                  <cflog text="#CFCATCH.Type# - #CFCATCH.Message# - #CFCATCH.Detail# - #CFCATCH.TagContext[1].line# - #CFCATCH.TagContext[1].Template#"> 

                  </cfcatch>

                  </cftry>

                      </cffunction>

                  </cfcomponent>

                   

                  - and nothing has appeared in any of the log files. Still the same results.

                  • 6. Re: CFGRID html with bind - not rendering, getting spinner
                    Libby H Level 1

                    I took some advice from the internet and ran the pages on Chrome.  I should have mentioned that this CFGRID renders as part of a cfinclude template that is inside a table that is inside a CFFORM.

                     

                    From the CROME browser, I get the following errors:

                     

                    Uncaught TypeError: Cannot read property 'appendChild' of null

                        at $G.Actions.init (cfgrid.js:412)

                        at Object.$G.init (cfgrid.js:140)

                        at _cf_GRIDTAG_initAjaxGrid_1488412230520 (index.cfm?fuseaction=tipsnewpayment:109)

                        at Object.fire (cfajax.js:1105)

                        at $E.windowLoadHandler (cfajax.js:1209)

                    $G.Actions.init @ cfgrid.js:412

                    $G.init @ cfgrid.js:140

                    _cf_GRIDTAG_initAjaxGrid_1488412230520 @ index.cfm?fuseaction=tipsnewpayment:109

                    fire @ cfajax.js:1105

                    $E.windowLoadHandler @ cfajax.js:1209

                    cfajax.js:804 Uncaught SyntaxError: parseJSON

                        at Object.decode (cfajax.js:804)

                        at Object.$X.processResponse (cfajax.js:521)

                        at Object.$X.callback (cfajax.js:501)

                        at _105 (cfajax.js:488)

                        at Object.$A.callback (cfajax.js:173)

                        at XMLHttpRequest.req.onreadystatechange (cfajax.js:125)

                    decode @ cfajax.js:804

                    $X.processResponse @ cfajax.js:521

                    $X.callback @ cfajax.js:501

                    _105 @ cfajax.js:488

                    $A.callback @ cfajax.js:173

                    req.onreadystatechange @ cfajax.js:125

                    • 7. Re: CFGRID html with bind - not rendering, getting spinner
                      haxtbh Level 4

                      Can you confirm  what QueryConvertForGrid actually returns. Doesnt it have valid data to pass to the grid?

                      • 8. Re: CFGRID html with bind - not rendering, getting spinner
                        Libby H Level 1

                        Yes it does. 

                        Before I added the bind and selectmode='row', I had the query="payment_all" statement in the CFGRID definition so the grid was being populated directly from the query.  The query itself hasn't changed (other than adding the 'order by cfif statement')..

                         

                        SELECT Payment_type, Payment_Desc

                        FROM paytype

                         

                        returns:

                         

                        001 ALDIS IXC TRNSFER

                        002 CERP

                        003 INTERCOMPANY DIVIDEND

                        004 EQUITY

                        005 FOREIGN PAYMENT

                        ...........

                        • 9. Re: CFGRID html with bind - not rendering, getting spinner
                          BKBK Adobe Community Professional & MVP

                          Use the following test code - with the CFM and CFC in the same directory - to verify whether the grid actually has access to the data.

                           

                          paymentgrid.cfm

                          <cfform>

                          <cfgrid format="html" name="paymentcodegrid"  height="254" width="315" pagesize="10" selectmode="row" striperows="yes" font="Arial" fontsize="10"

                          bind="cfc:payment.getData({cfgridpage},{cfgridpagesize},{cfgridsortcolumn},{cfgridsortdire ction})">

                          <cfgridcolumn name="Payment_Type" header="Payment Code" width="95" />

                          <cfgridcolumn name="Payment_Desc" header="Payment Description" width="200" />

                          </cfgrid>

                          </cfform>

                           

                          payment.cfc

                          <cfcomponent>

                          <cffunction name="getData" access="remote" output="false">

                              <cfargument name="page">

                              <cfargument name="pageSize">

                              <cfargument name="gridsortcolumn">

                              <cfargument name="gridsortdirection">

                           

                              <cfset var payment_all = "">

                             

                              <cfquery name="payment_all" datasource="Treasury">

                                  SELECT Payment_Type, Payment_Desc

                                  FROM paytype

                                  <cfif arguments.gridsortcolumn NEQ "" and arguments.gridsortdirection NEQ "">

                                      order by #arguments.gridsortcolumn# #arguments.gridsortdirection#

                                  </cfif>

                               </cfquery>

                              

                               <!--- Test: Verify whether the log file payment_all_qry.log contains any data --->

                               <cflog text="#serializeJson(payment_all)#" file="payment_all_qry">

                              

                              <cfreturn queryConvertForGrid(payment_all, arguments.page, arguments.pageSize)>

                             

                          </cffunction>

                          </cfcomponent>

                          • 10. Re: CFGRID html with bind - not rendering, getting spinner
                            Libby H Level 1

                            I feel as though I've pulled everyone down the wrong path here - because I think I've figured out my problem - but caused more questions for myself.  As I have mentioned before in some of my questions before, most of this code was written long, long ago beginning in 2000, using ColdFusion 4.5 and FuseBox 4 (I think).  As with many companies, I took over support back in 2007, and there has never been enough time or money to bring existing code up to snuff (or the latest version) and I am the sole developer and production support.

                            There is a  application.cfm but is it empty and all of the variable setting is done in appGlobals.cfm module. (I think this is a FuseBox thing.)  I have done more searching, and found a Forum discussion regarding 'spinning' and it mentions putting the line <cfargument name="thePage" type="string" required="true"> into your application.cfc OnRequestStart cffunction as a fix because the error is being trigger because the cfc bind is not completing before the page is rendered.  So, I mocked up an application.cfc and put

                            <cfsavecontent variable="content">

                                     <cfinclude template="appGlobals.cfm">

                            </cfsavecontent>

                            in the OnApplicationStart cffunction.  This fixed my problem - but as I stated, I think I have caused more questions for myself.

                             

                            My new application.cfm has code that Shared Hosting Environment mappings (based on variables.thisServerType) as well as cfmodule calls.  I don't know where exactly where to put this stuff in the application.cfc.  as well as y existing code has CFGRIDs embedded within CFFORMs throughout my application, and because changing CFGRID format=html needs the CFGRID encased with CFFORM, you can't embed one CFFORM within another. Right?  What a can of worms I have.

                            • 11. Re: CFGRID html with bind - not rendering, getting spinner
                              BKBK Adobe Community Professional & MVP

                              Libby H wrote

                               

                              ...
                              So, I mocked up an application.cfc and put

                              <cfsavecontent variable="content">

                                       <cfinclude template="appGlobals.cfm">

                              </cfsavecontent>

                              in the OnApplicationStart cffunction.  This fixed my problem - but as I stated, I think I have caused more questions for myself.

                              ...

                               

                               

                              The last statement summarizes the situation. You say the problem is fixed, but it is unclear what happened. It cannot be due to the cfsavecontent. The tag does nothing but define a variable called content. Besides, the scope of this variable is limited. Though it is defined in onApplicationStart, it is not an application-scoped variable. You mention onRequestStart, but it plays no part in your solution.

                               

                              Could it be that, by placing <cfinclude template="appGlobals.cfm"> within cfsavecontent, you effectively make appGlobals.cfm invisible? If so, then you could have achieved the same result by just removing the file appGlobals.cfm.

                               

                              Test the idea. Return the code to its previous state. Then temporarily rename the file to app_Globals.cfm. Does the problem go away? If so, then the cause of the problem is likely to be a setting in or regarding appGlobals.cfm.

                               

                              Another test. Place the code <cfoutput>#expandPath('.')#</cfoutput> at the top in paymentgrid.cfm. Is the resulting string E:\inetpub\WWWROOT\Treasury ?