Reputation: 51
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
Upvotes: 0
Views: 865
Reputation: 51
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);
Upvotes: 1