Results 1 to 6 of 6

Thread: Copy/Paste between Excel Sheet and GXT Grid

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1

    Default Copy/Paste between Excel Sheet and GXT Grid

    Hi All,

    Is there any way to do Copy/Paste between Excel Sheet and GXT Grid?

    If no, how can one do the following

    1. Use mouse drag over the GXT Grid to select a column, row, or column x row
    2. React to Ctrl + C and Ctrl + V events
    3. To Copy things from GXT Grid to the clip board for pasting on Excel?
    3. To Copy things from ClipBoard and transform and append the data in GXT Grid?

    Cheers,
    Rohit

  2. #2
    Sencha Premium Member
    Join Date
    Apr 2012
    Location
    London
    Posts
    16

    Default Paste clipboard into grid

    Hi,
    I have this requirement as well:
    3. To Copy things from ClipBoard and transform and append the data in GXT Grid?
    How did you solve it?

    User may copy from excel spreadsheet into the grid.

    Thanks
    Ozlem

  3. #3

    Default Paste from Excel sheet to GXT EditorGrid

    Hi Friends,

    We also have a similar requirement of pasting data from an excel sheet to a GXT Editor Grid.

    Is there a solution for GXT similar to the one below :-
    http://www.sencha.com/forum/showthre...able-tree-grid

    I am able to recognize CTrl + V button press, however i am not able to change focus to a hidden text-area as psoted in the above forum

  4. #4
    Sencha User
    Join Date
    Feb 2009
    Location
    Minnesota
    Posts
    2,737
    Answers
    109

    Default

    Can you be more specific? What happens when you do this, does it not receive focus correctly, or do you get an exception? Can you share a working sample of your code so that others can try it out and attempt to suggest changes?

    Note also that this thread is in the GXT forums, but the link you provided is Ext JS specific - these are completely different libraries, that just happen to look and feel much the same, but are implemented very differently.

  5. #5

    Default

    Thanks for getting back Colin!

    Here's some sample code :-


    grid.addListener(Events.OnKeyPress, new Listener<ComponentEvent>() {
    public void handleEvent(ComponentEvent ce) {

    if ((ce.getKeyCode() == 22) && ce.isControlKey()) {

    MessageBox.alert("You", "Pressed Ctrl + V", null);

    //Trying to shift focus to the hidden textarea
    hiddenTextArea.focus();

    //Value returned is null!
    String value = hiddenTextArea.getValue();

    MessageBox.alert("Value", value, null);
    }
    }
    });

    I saw a similar fix int the ExtJS forum, hence am wondering if there's a way we can achieve this in GXT also

  6. #6

    Default

    Complete code :-

    package com.test;
    import java.util.ArrayList;
    import java.util.List;
    import com.extjs.gxt.ui.client.data.BaseModelData;
    import com.extjs.gxt.ui.client.data.ModelData;
    import com.extjs.gxt.ui.client.event.ComponentEvent;
    import com.extjs.gxt.ui.client.event.Events;
    import com.extjs.gxt.ui.client.event.Listener;
    import com.extjs.gxt.ui.client.store.ListStore;
    import com.extjs.gxt.ui.client.widget.ContentPanel;
    import com.extjs.gxt.ui.client.widget.MessageBox;
    import com.extjs.gxt.ui.client.widget.Viewport;
    import com.extjs.gxt.ui.client.widget.form.TextArea;
    import com.extjs.gxt.ui.client.widget.grid.ColumnConfig;
    import com.extjs.gxt.ui.client.widget.grid.ColumnModel;
    import com.extjs.gxt.ui.client.widget.grid.EditorGrid;
    import com.extjs.gxt.ui.client.widget.layout.BorderLayout;
    import com.google.gwt.core.client.EntryPoint;
    import com.google.gwt.user.client.ui.RootPanel;

    /**
    *
    */
    public class TestApp implements EntryPoint {
    private Viewport viewport ;
    private EditorGrid<ModelData> grid;
    TextArea hiddenTextArea = new TextArea();

    @Override
    public void onModuleLoad() {

    viewport = new Viewport();
    ContentPanel centralPanel = new ContentPanel();
    centralPanel.setHeight(600);
    hiddenTextArea.setVisible(false);
    createDataInputGrid();


    centralPanel.add(hiddenTextArea);
    centralPanel.add(grid);

    viewport.setLayout(new BorderLayout());
    viewport.add(centralPanel);
    RootPanel.get("test_content").add(viewport);

    }
    private EditorGrid<ModelData> createDataInputGrid() {
    List<ColumnConfig> columns = getColumnConfig();
    ColumnModel columnModel = new ColumnModel(columns);
    ListStore<ModelData> store = new ListStore<ModelData>();
    grid = new EditorGrid<ModelData>(store, columnModel);//new ColumnModel(columns));
    grid.setBorders(true);
    grid.setStripeRows(true);
    grid.setAutoExpandMin(150);
    grid.setColumnLines(true);
    grid.setHeight(500);

    grid.addListener(Events.OnKeyPress, new Listener<ComponentEvent>() {
    public void handleEvent(ComponentEvent ce) {

    if ((ce.getKeyCode() == 22) && ce.isControlKey()) {

    MessageBox.alert("You", "Pressed Ctrl + V", null);

    //Trying to shift focus to the hidden textarea
    hiddenTextArea.focus();

    //Value returned is null!
    String value = hiddenTextArea.getValue();

    MessageBox.alert("Value", value, null);
    }
    }
    });

    ModelData data1 = new BaseModelData();
    data1.set("column1", "value 1");
    data1.set("column2", "value 2");

    ModelData data2 = new BaseModelData();
    data2.set("column1", "value 3");
    data2.set("column2", "value 4");

    grid.getStore().add(data1);
    grid.getStore().add(data2);

    return grid;
    }

    private List<ColumnConfig> getColumnConfig(){

    List<ColumnConfig> configs = new ArrayList<ColumnConfig>();
    configs.add(new ColumnConfig("column1", "Column 1", 80));
    configs.add(new ColumnConfig("column1", "Column 2", 80));
    return configs;
    }




    }

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •