1. #1
    Ext GWT Premium Member
    Join Date
    Oct 2010
    Posts
    2
    Vote Rating
    0
    dbulla is on a distinguished road

      0  

    Default Getting the grid to respond to pasted text (post-paste processing)

    Getting the grid to respond to pasted text (post-paste processing)


    I'm having a problem where we've got a grid with editable cells (we extended EditorSupport). As part of our app, we have to be able to handle text folks paste into cells via CTRL-V, and then do some post-processing (paste from a spreadsheet, so we have to parse the actual text, then figure out how to jigger the model to reflect what the pasted text is supposed to be).

    The problem comes in that our business users want this to happen with just CTRL-V. I can get it to parse the text properly if the users navigate away from the cell via ENTER, TAB, etc - that triggers the onEditComplete() method of our extended EditorSupport class. But, that doesn't get triggered by just pasting. If you add a listener to the editor's text field, it doesn't seem to have the ability to signal the edit event is complete.

    Any ideas? I'm fairly new to GXT, and these requirements are pretty inflexible ("It should work just like Excel"), so I'm trying to work around them


    Thanks in advance,

    Doug

  2. #2
    Ext GWT Premium Member
    Join Date
    Oct 2010
    Posts
    2
    Vote Rating
    0
    dbulla is on a distinguished road

      0  

    Default


    We got it figured out - we extended TextField for the editor, and added some logic as shown below. We listen for two events - ONPASTE, and a subsequent ONKEYUP. That lets the browser complete the paste event, and then we can parse the pasted text (we're pasting from a spreadsheet) to figure out what cells to add.

    The code in our extended TextField looks like this:

    Code:
      private boolean            isPaste;  //keep track of whether we're in a paste event 
    
      OrderGridField(OrderGridViewModel viewModel)  // contructor for our class
      {
        this.viewModel = viewModel;
        sinkEvents(ONPASTE);  // this tells the dom we're interested in events
      }
    
      @Override
      public void onBrowserEvent(Event event)
      {
        String rawValue       = getRawValue();
        String originalValue1 = getOriginalValue();
    
        super.onBrowserEvent(event);
    
        if (event.getTypeInt() == Event.ONPASTE)  // handle a paste event - if we tried to process the text right now,
                                                                       // the browser wouldn't have handled it yet.  So, we have to wait 
        {
          isPaste = true; //set the paste flag to true
        }
    
        if ((event.getTypeInt() == Event.ONKEYUP) && isPaste) // We have a key up after a paste event - now the text has been pasted and is available for parsing
        {
          viewModel.parsePaste(rawValue, editor.row, editor.col); //call the model to handle the pasted text (which will paste into other cells as well as this one)
          isPaste = false;  // unset the paste flag
        }
      }

Similar Threads

  1. How to enable text selection (and copy-paste) in Grid
    By eugenparaschiv in forum Ext GWT: Help & Discussion (1.x)
    Replies: 6
    Last Post: 2 Feb 2012, 9:07 PM
  2. Htmleditor override to remove office document markup from pasted text
    By KRavEN in forum Ext 2.x: User Extensions and Plugins
    Replies: 1
    Last Post: 28 Sep 2009, 10:44 AM
  3. Post processing tab content?
    By thewoodsman in forum Ext 1.x: Help & Discussion
    Replies: 1
    Last Post: 17 Jan 2008, 9:38 AM

Tags for this Thread

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi