2 Replies Latest reply on Oct 10, 2007 4:19 AM by Derrick_DC

    CFGRID Dynamic PageSize

    Derrick_DC
      Hi All,

      I am using CFGIRD with a pagesize of 25. However in some cases the recordSet returned is less than 25 records and therefore the grid will have blank space.

      Does anyone know if it is possible to dynamicaly change the size of a cfgrid based on the number of records returned?
        • 1. Re: CFGRID Dynamic PageSize
          Level 7
          Derrick_DC wrote:
          > Hi All,
          >
          > I am using CFGIRD with a pagesize of 25. However in some cases the recordSet
          > returned is less than 25 records and therefore the grid will have blank space.
          >
          > Does anyone know if it is possible to dynamicaly change the size of a cfgrid
          > based on the number of records returned?
          >

          easy. in your cfc:
          1) add <cfset var ps = arguments.pagesize> after the arguments
          declarations (assuming your argument that receives {cfgridpagesize}
          value is named pagesize)
          2) assuming you have a query named myQuery which pulls the data fro grid
          from the db, add the following line AFTER the query: <cfif
          myQuery.recordcount lt arguments.pagesize><cfset ps =
          myQuery.recordcount></cfif>
          3) your cfreturn line should then be: <cfreturn
          queryConvertForGrid(myQuery, arguments.page, ps)

          hth

          --

          Azadi Saryev
          Sabai-dee.com
          http://www.sabai-dee.com
          • 2. CFGRID Dynamic PageSize
            Derrick_DC Level 1
            Thanks Azadi. This worked perfectly. I read the first line of your response and immediately knew what to do. I can't believe how easy it was.