Skip to main content
April 15, 2010
Question

cfgrid insert row with default value

  • April 15, 2010
  • 1 reply
  • 2560 views

Seems like this should be straightforward...

I have a cfgrid that allows a user to insert a new row (insert='yes').

One column in the cfgrid is hidden but carries the uniqueID.

Upon updating changes back to the table in the db, I need for that field to be populated w/the correct uniqueID (CR_ID).

All the rows in this table would have  the same ID b/c they are being called from a query based on that ID.

It is important that the ID row is not itself editable.  I simply want  to use post the correct ID back to the db for that new row, instead of  having an empty cell.

<cfgrid
        name="idGrid"
        title="Related IDs"
        query="get_IDs"
        selectmode="edit" insert="yes" insertbutton="Insert New ID" enabled="yes" visible="yes"
        format="html" preservepageonsort="true">
      <cfgridcolumn name="CR_ID" display="No" select="no"/>
      <cfgridcolumn name="ID" header="ID" />
      <cfgridcolumn name="IDType" header="ID Source" values="#r_idType#" valuesdisplay="#r_idType#" valuesdelimiter=","/>
    </cfgrid>

was populated by:

<!-- query all ID records based on passed CR_ID -->
<cfquery name="get_IDs" datasource="bridges">
SELECT tblIDs.CR_ID, tblIDs.ID, tblIDs.IDType
FROM tblIDs
WHERE tblIDs.CR_ID = '#CFGRIDKEY#'
</cfquery>

Need to post chages to records in cfgrid including any new rows with that CR_ID put into the field for the new record!

    This topic has been closed for replies.

    1 reply

    Participating Frequently
    May 5, 2010

    You must add cfgrid parameter:

    onChange="idGrid.dataProvider.editField(idGrid.selectedIndex,'IDType', '#r_idType#');"

    sajjansarkaratlanta
    Participating Frequently
    June 21, 2010

    Hi,

    Thanks for the reply, I have the same problem. The suggestion you gace did not work as it works only for flash grids. I am using an HTML grid.I just want to set a default value of OLST to the Client column. Please help!

    <cfgrid name = "FirstGrid"

    format="html"

    height="320"

    width="580"

    font="Tahoma"

    fontsize="12"

    query = "rsIncidentTypes"

    bgcolor="orange"

    selectmode="edit"

    selectcolor="teal"

    delete="true"

    insert="true"

    insertButton = "Insert a Row"

    deleteButton = "Delete selected row"

    onChange="FirstGrid.dataProvider.editField(FirstGrid.selectedIndex,'Client', 'OLST');"

    >

    Participating Frequently
    June 27, 2010

    True, this code is action script... only for flash.   I can't do for html grids, I resolve this issue in my sites in data layer.  After I save the grid I update the table whit the value that I need.  .  Here we call this "machetazo".