Check documentation for the latest version 6.0 of dhtmlxSuite beforeOutput DHTMLX Docs

beforeOutput

The event occurs event occurs after data has been selected from the database and ready to be sent to client side. Event can be used to mix some custom data in XML output. The most common use-case - header structure for the grid.

<cfset conn.event.attach("beforeOutput",handlerFunc)>

Parameters handlerFunc:

  • Doesn't get any parameters

Availability:

  • Available for Grid, TreeGrid, Tree, Combo, Scheduler, DataView, Chart, Form

Sample:

<cffunction name="grid_header">
    <cfargument name="connector" type="any" hint="Grid Connector Object">
    <cfargument name="out" type="any" hint="Output Writer">
    <cfset var header = "">
    <cfif not isDefined("URL.posStart")>
        <cfsavecontent variable="header">
        <cfoutput>
            <head>
                <column width="50" type="ed" align="right" color="white" sort="na">Sales</column>
                <column width="150" type="ed" align="left" color="##d5f1ff" sort="na">Book Title</column>
                <column width="100" type="ed" align="left" color="##d5f1ff" sort="na">Author</column>
            </head>
        </cfoutput> 
        </cfsavecontent>
        <cfset ARGUMENTS.out.add(header)>
    </cfif>     
</cffunction>
<cfset grid = createObject("component","dhtmlXConnectors.GridConnector").init("#datasource#","MYSQL")>
<cfset grid.event.attach("beforeOutput",grid_header)>
<cfset grid.render_table("grid50000","item_id","item_id,item_nm,item_cd")>

In case of dyn. loading mode, one more check need to be added, to prevent data output for additional data calls:

<cffunction name="grid_header">
    <cfargument name="connector" type="any" hint="Grid Connector Object">
    <cfargument name="out" type="any" hint="Output Writer">
    <cfset var header = "">
    <cfif not isDefined("URL.posStart")>
        <cfsavecontent variable="header">
        <cfoutput>
            <head>
                <column width="50" type="ed" align="right" color="white" sort="na">Sales</column>
                <column width="150" type="ed" align="left" color="##d5f1ff" sort="na">Book Title</column>
                <column width="100" type="ed" align="left" color="##d5f1ff" sort="na">Author</column>
            </head>
        </cfoutput> 
        </cfsavecontent>
        <cfset ARGUMENTS.out.add(header)>
    </cfif>     
</cffunction>
<cfset grid = createObject("component","dhtmlXConnectors.GridConnector").init("#datasource#","MYSQL")>
<cfset grid.dynamic_loading(100)>
<cfset grid.event.attach("beforeOutput",grid_header)>
<cfset grid.render_table("grid50000","item_id","item_id,item_nm,item_cd")>
Back to top