Announcement

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

    Select and Unselect record on ListGrid

    Hi,

    I would like to set a specific selectionType for my ListGrid :

    In fact I want to have the following mode :

    * single selection (as in the SINGLE mode)
    * AND possibility to unselect the selected row by clicking it (toggle mode like in SIMPLE mode)

    How may I do that ? I think that this hybrid mode should be added in the SelectionType for ListGrid.

    Thank you for your help

    Respect

    #2
    If you're running against SVN, you can add

    Code:
    grid.setSelectionAppearance(SelectionAppearance.CHECKBOX);
    This will place a checkbox in the first column for selection where you can toggle selection.

    Sanjiv

    Comment


      #3
      Hi Sanjiv,

      in fact I have a form linked to my grid so your solution is not good for me because I want to avoid multiselection to avoid messing the users with the form display.

      Just adding the unselect possibility to the SINGLE mode would be great !!

      Regards

      Comment


        #4
        You could simply add a click listener that deselects the row it is already selected.

        Sanjiv

        Comment


          #5
          Hi Sanjiv,

          this is exactly the idea I had. But how can I deselect the selected row ? There is no such method on grid or on rowclickevent as far as I know.

          Regards

          Comment


            #6
            Have you tried ListGrid.deslectRecord along with ListGrid.addRecordClickHandler(..)?

            Sanjiv
            Last edited by sjivan; 17 Jan 2009, 00:03.

            Comment


              #7
              oops
              thank you sanjiv
              I was exploring all the grid methods and I don't know how I missed the deselect methods that fit my need.

              Thank you !!

              Regards

              Comment


                #8
                There is:
                setSelectionType (SelectionStyle.SINGLE);
                but it doesn't seems to do anything in my code
                (I am using smartgwt-1.0b2.zip, I got it at 10/Jan/2009)
                Is it a bug and it will be fixed?

                Comment


                  #9
                  SINGLE mode only allows you to select one record at a time
                  You can't deselect it on clicking on it once again. To do so please use the method deselectRecord as given by sanjiv ;)

                  Regards

                  Comment


                    #10
                    No, I mean that even if I set SelectionStyle.SINGLE, the mode remains MULTIPLE.
                    The SINGLE mode is not working in my case (not in ListGrid or even in TreeGrid)

                    Comment


                      #11
                      This sample users SelectionStyle.SINGLE and works fine in the SVN build.

                      Comment


                        #12
                        hum,

                        I have to admit that the SINGLE mode seems to not work well : I have same issue on grids : I set them to SINGLE mode by adding

                        setSelectionType(SelectionStyle.SINGLE);

                        to my grid but I still can multiple select data in this grid.

                        I don't know how the example in the showcase is working, it seems to just call the same method than above.

                        Any idea ?

                        Respect

                        Comment


                          #13
                          Can anyone post a standalone test case that actually demonstrates the issue?

                          Comment


                            #14
                            setSelectionAppearance

                            Code:
                            setSelectionAppearance(SelectionAppearance.CHECKBOX)
                            congratulations on that!
                            works great and is exactly what I needed!

                            Comment


                              #15
                              The following code creates a working LlistGrid but it fails to set the SelectionStyle.SINGLE


                              public class ListGridCriteria extends ListGrid
                              {
                              private ListGridField m_fieldCriterio, m_fieldValue;

                              public ListGridCriteria ()
                              {
                              setWidth100 ();
                              setHeight100 ();

                              setSelectionType (SelectionStyle.SINGLE);

                              m_fieldCriterio = new ListGridField("criterio", "Κριτήριο", 60);

                              m_fieldValue = new ListGridField("value", "Τιμή");
                              m_fieldValue.setWidth ("*");

                              setFields (m_fieldCriterio, m_fieldValue);

                              loadListGrid ();
                              }
                              private void loadListGrid ()
                              {
                              ListGridRecord[] rr = new ListGridRecord[5];
                              for (int i=0; i<5; i++)
                              {
                              ListGridRecord r = new ListGridRecord ();
                              r.setAttribute ("criterio", "criterio");
                              r.setAttribute ("value", "value");
                              rr[i] = r;
                              }

                              setData (rr);
                              }
                              }

                              Comment

                              Working...
                              X