0

In CF9 with IE8 I have a cfgrid that is bound to a text (search) field as well as a cfc function. The text field value is used as a query filter within the cfc function. If any results are found, the grid gets populated. Otherwise, I would like to send an alert to user like "No records found"

I couldn't find anything able to do this, as both javascript and CF tags seem to be simply ignored inside a cfc, i.e.

<cfif myQry.recordCount eq 0> No records found <cfabort></cfif>

or

<cfif myQry.recordCount eq 0> 
    <script> 
        alert("No records found"); 
    </script>
</cfif>

Thanks for any suggestions

Leigh
  • 28,765
  • 10
  • 55
  • 103
ion
  • 51
  • 1
  • 7
  • I'm surprised this is still unanswered. You don't show the entire component code, but my first thought is that it's set with output="no". The other option is that if you have enablecfoutputonly="yes" set either in the code or in the cfadmin, then you'll need to put cfoutput tags around any code to make it display. – Sharondio May 07 '12 at 22:23
  • FYI, CF questions get more attention if you also include one of the core tags: `cfml` for questions about CFML in general and/or `coldfusion` for Adobe specific questions. – Leigh Apr 19 '13 at 21:43

1 Answers1

1

It actually proved to be more complicated than I thought. I've tried a couple of things I discovered, like the ajaxOnLoad statement or the onLoad event of the grid, but they didn't work as expected. Finally I solved it with a js function like:

    getTotalRows = function() {
    var isGrid = ColdFusion.Grid.getGridObject('myGrid');
    var isData = isGrid.getStore();
    isData.addListener("load", function() {
  if(isData.totalLength == 0)
    {
    alert("No records found");
    return false;
        }
    });
  }
  ColdFusion.Event.registerOnLoad(getTotalRows,null,false,true);
Leigh
  • 28,765
  • 10
  • 55
  • 103
ion
  • 51
  • 1
  • 7