Link to home
Start Free TrialLog in
Avatar of Panos
PanosFlag for Germany

asked on

cfgridcolumn validation

Hello experts.
I need help to validate editable cfgridcolumns.
I found a tutorial on this page:http://ajaxian.com/archives/coldfusion-8-grid-magic but i still have problems.
In this example the script is checking if it is a number.I also need to know how it works if i need to check for required fields,maxlength...
Any help?

My cfgrid:
 <cfgrid name="Kategoriegrid" format="html" pagesize="30" insert = "Yes"   sort="yes" width="100%"
    rowheaderbold="yes" colHeaderBold = "Yes"    pictureBar="yes" hspace="0" vspace="0"  bind="cfc:cfc.kategories.getKategories({cfgridpage},{cfgridpagesize},{cfgridsortcolumn},{cfgridsortdirection},{filtercolumn},{filter})" selectmode="edit" onchange= "cfc:cfc.kategories.updateKategories({cfGridAction},{cfgridrow},{cfgridchanged})">
      <cfgridcolumn name="TABLE_ID" header="Table_id"  select="no" display="false"/>
      <cfgridcolumn name="KAT_ID" header="Kat ID" width="30" numberformat="9" <!--- select="no" ---> display="false"/>
      <cfgridcolumn name="KAT_TEXT" header="Text" />
      <cfgridcolumn name="mobiles_sub_id" header="Mobile" select="no"/>
      <cfgridcolumn name="LangID" header="LangID"  select="no"/>
      
   </cfgrid>
<cfset AjaxOnLoad("init")>

my js:
<script language="JavaScript" type="text/javascript">
dataValidator = function(editEvent){
	if (editEvent.field == "Kat_ID"){

         if (isNaN(editEvent.value)){
            alert("Please enter a numeric value in this field.");
            editEvent.cancel = true;
         }
      }
   }
   addValidator = function(){
      mygrid = ColdFusion.Grid.getGridObject('Kategoriegrid');

      mygrid.on('validateedit',dataValidator);
   }
   init = function(){
      addValidator();
   }
</script>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Pravin Asar
Pravin Asar
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
data validators do not check the required fields, max length , etc.

These you need to implement at clientside (Javascript) and at serverside too.
Avatar of Panos

ASKER

Hi pravinasar.
Can you help me with the clientside (javascript) validation.I usually use jquery validation for form fields,but how is this working with the gridcolumns:
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Panos

ASKER

thank you for your help
regards
panos