Author Topic: Pasting into cells should potentially run editors  (Read 2203 times)

nebels

  • Pro Enterprise
  • Newbie
  • *
  • Posts: 12
    • View Profile
Pasting into cells should potentially run editors
« on: July 21, 2015, 02:48:25 am »
Hi there,

We found an interesting behaviour with regard to pasting into cells. Say you have a custom cell editor using for instance jquery.inputmask. The editor only allows certain characters and discards chars which are not in in the allowed character set.
If a given cell is in input mode all is fine and the editor does what it is supposed to do - keeping the associated data 'clean'.

If the user pastes data - either by pasting multiple cells or by putting the given cell into selected mode (but not input)  by pressing Escape -  all characters are pasted - even the ones which would have be taken out otherwise by the editor had the cell been in input mode. The net result is that the underlying datamodel now contains data which is not allowed.  The grids also displays this data.
There is of course a way around the display issue by using render, and also validations could be used, but from my understanding in the case of paste (as outlined above) there is no way to fix the data pasted.

Any hints are very much appreciated.

 
 

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6122
    • View Profile
Re: Pasting into cells should potentially run editors
« Reply #1 on: July 22, 2015, 12:53:01 am »
beforeValidate event is fired before the pasted data is added to the grid so any processing of the pasted data can be done in this event.

http://paramquery.com/pro/api#event-beforeValidate

Example implementation of the event discussed in this post: http://paramquery.com/forum/index.php?topic=1106.msg5285#msg5285
« Last Edit: July 22, 2015, 01:09:44 am by paramquery »