Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Copying ListGrid cell values to clipboard

    Is it possible to copy data from ListGrid to clipboard? It seems to me that if ListGrid is not editable, user cannot select text from cells to copy it (using Ctrl+C).

    If I make ListGrid editable (so that user can select text when editor opens) how can I prevent user to make changes? I have tried calling cancelEditing() method in EditorExitHandler but then I get StackOverflowError, because I am getting infinite loop.

    Btw, there is a bug when method event.getEditCompletionEvent() is called in EditorExitHandler, as this Exception is thrown (I guess you should just uppercase argument in valueOf()):
    Code:
    Uncaught JavaScript exception [java.lang.IllegalArgumentException: No enum const class com.smartgwt.client.types.EditCompletionEvent.click
    	at java.lang.Enum.valueOf(Enum.java:196)
    	at com.smartgwt.client.types.EditCompletionEvent.valueOf(EditCompletionEvent.java:1)
    	at com.smartgwt.client.widgets.grid.events.EditorExitEvent.getEditCompletionEvent(Native Method)

    #2
    EditCompleteEvent.getEditCompletionEvent() fixed in SVN. You could try calling cancelEditing() in a GWT DeferredCommand.
    Last edited by smartgwt.dev; 12 Feb 2009, 15:36.

    Comment


      #3
      Thanks. It works now.

      Comment


        #4
        Will there be any way to provide the clipboard functionality without making the grid editable? It might confuse things for the user to allow them to appear to change the field but than cancel the changes. Especially since there will be other Grids in the application which are editable.

        As a short-term alternative is there something in the EditCompleteHandler (EditCompleteEvent) or EditorExitHandler (EditorExitEvent) which will allow me to cancel the changes the user made? I've tried the EditorExitEvent cancel method but that does not seem to undo the changes.

        Thanks
        Last edited by capertown; 17 Feb 2009, 13:25.

        Comment


          #5
          Any thoughts on this issue? Why we make text not selectable by default on all GUI components? setCanSelectText() doesn't seems to work on ListGrid.

          Thanks.

          Comment


            #6
            It's not on by default because drag selection of text is mutually exclusive with other possible drags (like dragging records).

            You need to set canSelectText on the ListGrid's *body*. Right now this requires JSNI until the AutoChild system is usable from SmartGWT.

            Comment


              #7
              Originally posted by Isomorphic
              It's not on by default because drag selection of text is mutually exclusive with other possible drags (like dragging records).

              You need to set canSelectText on the ListGrid's *body*. Right now this requires JSNI until the AutoChild system is usable from SmartGWT.
              I've figured out how to access the native javascript from the Java side but am not familiar with how to select the *body* or to set canSelectText. Can you provide a quick snippet of code?

              Comment


                #8
                @wwoley Take a look at ListGrid.java in SVN - there are several examples, a close one is scrollBodyTo()

                Comment


                  #9
                  Thanks Isomorphic -- I'll try it tomorrow at work.

                  BTW - Awesome software!

                  Comment


                    #10
                    Thanks again -- the example was really close. For anyone else looking for the programatic solution, here's what I used:

                    n.b. it's also necessary to turn off all drag settings on the listGrid.
                    I called this method after the listGrid object was drawn -- not sure if that's important, but it made sense.

                    public native void setListGridBodyCanSelectText(ListGrid listGrid, Boolean canSelectText)/*-{
                    var lg = listGrid.@com.smartgwt.client.widgets.BaseWidget::getOrCreateJsObj()();
                    var body = lg.body;

                    body.canSelectText = canSelectText;
                    }-*/;

                    Comment


                      #11
                      Added added ListGrid.setCanDragSelectText(boolean) to SVN.

                      Sanjiv

                      Comment


                        #12
                        Copying ListGrid cell values to clipboard

                        Sanjiv, in what version of smartGWT is the ListGrid.setCanDragSelectText(boolean) method added?

                        Thanks,
                        Tim

                        Comment


                          #13
                          It was added post 1.3.

                          Comment


                            #14
                            Thanks so much! This helped me a lot! If it helps, if you're doing this in Javascript, you can do something like:

                            isc.ListGrid.create({
                            ID:"myGridId",
                            top:180,
                            left:80,
                            width:"100%"
                            });
                            myGridId.body.canSelectText = true;

                            Comment


                              #15
                              We know that the drag&drop select rows and the drag&drop select text are exclusive.

                              Also when we keep left-shift down, both are selected: text and rows.

                              Can we enable the select text only if the selected row size is strict-lower than 1?
                              --> This could let users to select one cell text without disabling the drag&drop select row.

                              Can we imagine a special key pressed to switch at execution time between drag&drop text and drag&drop rows?
                              --> This could let users to choose what to select.

                              Can we add a feature to enable the key-shortcut "ctrl+c" to copy into the end-user computeur clipboard the content of the selected rows?
                              --> This could let users to copy/paste listgrid data and do what they want with.

                              Thank you for your advises.
                              Last edited by enguerran; 8 Sep 2010, 04:02.

                              Comment

                              Working...
                              X