Skip to main content
Participant
March 26, 2010
Question

cfgrid, bind with additional arguments?

  • March 26, 2010
  • 1 reply
  • 2692 views

Hi

I'm new to CF and love what it can do quickly but then get very frustrated.

I'm using a cfgrid and have worked out that for paging I need to use bind rather than just a query result.

<cfgrid bind="cfc:events.GetEvent( {cfgridpage},{cfgridpagesize},{cfgridsortcolumn},{cfgridsortdirection} )"  name="eventGrid" format="html" striperows="yes" pagesize="15"  >  

However, I  want to pass parameters to the funtion so I can filter the data being returned. Everything I've tried gives an error. Where in the <cfgrid code do I put the additional argument ? (in this  case a date)

I've tried all sorts of things like the line below but with no success...

<cfgrid bind="cfc:events.GetEvent( {cfgridpage},{cfgridpagesize},{cfgridsortcolumn},{cfgridsortdirection}, {#now()#}  )" ... >   

Thanks

    This topic has been closed for replies.

    1 reply

    Fernis
    Inspiring
    March 26, 2010

    Quote from http://www.garyrgilbert.com/blog/index.cfm/2007/6/14/Coldfusion-8s-CFGRID , said by Gary Gilbert:

    In order to do that you would bind the grid to the onchange event of the  cfselect.  To do that you would change the bind expression on your  grid.
    <cfselect name="myselect" bind="cfc:mycfc.getSelectData()"  bindonload="true">
    <cfgrid .....  bind="cfc:mycfc.getGridData({cfgridpage},{cfgridpagesize},{cfgridsortcolumn},{cfgridsortdirection},{myselect})"

    Quote from http://cfsilence.com/blog/client/index.cfm/2007/8/9/Filtering-Records-In-An-Ajax-Grid , by Todd Sharp

    <cfgrid 
        format="html"
        name="artGrid"
        pagesize="5"
        sort="true"
        bind="cfc:art.getArt({cfgridpage},{cfgridpagesize},{cfgridsortcolumn},{cfgridsortdirection}, getSearchString())">

    <script>
    getSearchString = function(){
        var s =  ColdFusion.getElementValue('searchString');
        return s;
    }
    </script>

    The above examples explain you how you cannot just write anything between the curly brackets - it's gotta be a DOM object name, not some ColdFusion variable value.

    Not having tried cfgrid filtering myself lately, I'd try first a simpler example, like

    bind="cfc:art.getArt({cfgridpage},{cfgridpagesize},{cfgridsortcolumn},{cfgridsortdirection}, '#dateformat(now(),'m/d/yyyy')#'"

    That'll pass your CFC the date in Month/Day/Year format (note the single quotes!). Then your make your back end filter the data which will be returned.

    --

    - Fernis - fernis.net - ColdFusion Developer For Hire

    Participant
    March 29, 2010

    Thanks!

    Not sure I understand a word but will  give it a go...