how to catch change events for date component

I have following sample code.

there are 2 fields. plain text field ID, and date field valueDate.
I have change method at field level for both fields.
Whenever user changes values on text fields corr message is printed.
But for data component message is not getting printed when user directly enters on date text field or chooses date from datechooser.

How should i go about it?

I have tried using

 editorProperties : { 
    		  			change: function (form, item, value, oldValue) 
    		  			{
    		  				isc.logWarn("value date changed row "+item.rowNum);
    		  			}
    		  		     }

for valuedate field.

var realTimeRateGrid = isc.ListGrid.create({
    	ID: "myGrid",
	left:175, top:220,
	autoDraw:true,
    	width:300, height:225, 
    	canEdit: true,editEvent: "click",
    	alternateRecordStyles:true, showAllRecords:true, cellHeight:22,neverValidate: true,
    	fields:[
    		{ name:"record",title:"ID",type:"text", width:50,
    		  editorProperties : { 
    		  			change: function (form, item, value, oldValue) 
    		  			{
    		  				if(! isA.emptyString(value) && value.length > 5)
    		  					return false;
    		  				return true;
    		  			}
    		  		     }
    		},
    		{name:"valueDate", wrapTitle:true, title:"ValueDate", type:"date",width:50,
    		 
    		  change: function (form, item, value, oldValue) 
    		  			{
    		  				isc.logWarn("value date changed row "+item.rowNum);
    					
    		  			}
    		 
    		  			
    		}
    		
	 ],
	 data:[
        	{record:"1", valueDate:""},
        	{record:"1", valueDate:""}
        ]
});

Hi Mithun,

The DateItem normally only fires change() when the user has entered a valid date value. So, you won’t receive change() notifications from text entry until the user enters a complete date and leaves the field.

You will get a change() notification from dates selected via the DateChooser and we are seeing them with the code you provided.

If you want finer-grained notifications, you could get them via the keyboard events available on all FormItems (keyPress, etc). However, what are you trying to do with the change() notification? There may be a better approach.

yes you are right, change() works for date component also with code i sent.
Actually i didnt give you complete code.

before grid definition i sent i have some Date class setup code

Date.setInputFormat("DMY");

function userPrefDateFormatter () 
{     
		var selDate = this.getDate() + "";
        	var selMonth = this.getMonth() +1 + "";
        	
        	var date = ("0"+selDate).substring(selDate.length - 1,selDate.length + 1);
        	
        	var month = ("0"+selMonth).substring(selMonth.length - 1,selMonth.length + 1);
        	
        	return date + "." + month + "." + this.getFullYear();
}

Date.setShortDisplayFormat(userPrefDateFormatter); 



//----------------------------------------------------------------------------
// Isomorphic SmartClient 6.0 patch
// Purpose: Expliicitly disallow 3 digit day / month in date string using custom
//  YYYY.MM.DD format
// 
// Applies to SmartClient 6.0 builds only 
//----------------------------------------------------------------------------
if (window.isc && isc.version.startsWith("6.0/")){ 

isc.DateItem.addMethods({
_opd:isc.DateItem.getPrototype().parseDate,
parseDate:function (dateString, inputFormat) {
    if (isc.isA.String(dateString)) {
        var dateArray = dateString.split(".");
        if(dateArray.length != 3)
        	return null;
        if ( ( dateArray[0].length != 4 ) || (dateArray[1] && dateArray[1].length != 2) || (dateArray[2] && dateArray[2].length != 2)) 
        	return null;
    }
    return this._opd(dateString,inputFormat);
}
});

} else if (window.isc) {
  isc.Log.logWarn("Patch for SmartClient 6.0 builds included in this application. " +
            "You are currently running SmartClient verion '"+ isc.version + 
            "'. This patch is not compatible with this build and will have no effect. " +
            "It should be removed from your application source.");

}

/// END PATCH

i have neverValidate: true for list grid. This patch i got as answer of the post
http://forums.smartclient.com/showthread.php?t=1310&highlight=suppressing.

What i found is code without this date setup above works fine for change() as you observed.

With this code change() method is not getting triggered. This date patch is required to me to solve some date validation issues as mentioned in specified thread.

So is there anything missing in patch to handle change event ?

The patch you were given applies only to YMD date input, as it says in the comments of the patch itself. You have switched to DMY input.

Do you forsee switching yet again? The patch can be easily converted to expect DMY instead, or, a more general purpose patch can be prepared or you can work from a beta build.

Thanks for suggestion. Now parse method is changed to handle dd.mm.yyyy
dates. And input format is DMY.
With this i get change method triggered immediately when i select date from date chooser. But when i change it directly inside date text box to some other valid date change is called only when i click on some field ie. on focus out.

For other text field (mentioned in my previous sample code in this thread) change is called just when its contents are changed.

So how can i get immediate change notification in case of direct edits of dates ?

_opd:isc.DateItem.getPrototype().parseDate,
parseDate:function (dateString, inputFormat) {
    if (isc.isA.String(dateString)) {
        var dateArray = dateString.split(".");
        if(dateArray.length != 3)
        	return null;
        if ( ( dateArray[0] && dateArray[0].length != 2 ) || (dateArray[1] && dateArray[1].length != 2) || (dateArray[2] && dateArray[2].length != 4)) 
        	return null;
    }
    

        	return this._opd(dateString,"DMY");

    
}

As previously indicated, you can use the FormItem.keyPress event.

And as previously asked, what are you trying to do on a per-keystroke basis? We can probably suggest a better approach.

I need change event because i have to stop one timer if there is any change on date field and some other field on this row. Actually i need immediate callback no matter user entered date is valid or invalid.

Immediate callback comes for other text field and i am able stop this timer but when user enters any valid / invalid characters on date field timer still continues to run.
Only on focus out of valid change i get callback.

So there is significant difference in my timer operation for diffierent field editing.

I will try with keyPress event.

Do you think of any better approach ?

If you really need to react as soon as the user types a key in an edited field, then yes, keyPress() in the right approach. Just be sure to ignore keys that imply cell-to-cell navigation such as Tab, Shift-Tab, and Up and Down arrow.

Alternatively, if it’s sufficient to stop your timer when the user actually completes an edit rather than on the first keystroke, you could just use editorExit() and check if the editValues for the record differ from the original record. We don’t know knowing everything about your requirements, but this does seem like better UI.