Announcement

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

    How to add Radio Buttons in coulns i.e. ListGridField

    Hi,

    I am very new to GWT and this forum. I want to create a List Grid where Columns can contain Radio buttons, i.e. ListGridField should be allowing user to select values for each row.
    I have seen some examles to add Radio Button to ListGrid that allows to select one of the rows, however not seen example of individual columns having radio button.

    Thanks.


    #2
    Radio buttons are generally a poor choice for editing in a grid, since they are not space-efficient. However, if you want to do it anyway, set listGridField.editorType to RadioGroupItem.

    Comment


      #3
      Thanks for above suggestion, I was able to add Radio button to ListGridField. However I have one issue, this radio button is only visible when particular record is edited. How can I show the radio buton always on.
      please advise.

      Click image for larger version

Name:	RadioButton in grid.PNG
Views:	58
Size:	4.1 KB
ID:	258703

      Comment


        #4
        You would need to either set alwaysShowEditors or use showRecordComponents instead.

        Comment


          #5
          I used showRecordComponents , t did not worked.. when I try alwaysShowEditors it does show radio buttons when selected ( But doesnt show radio buttons for all records ). Also once radio button is visible, grid record looses its selection ( i.e Grid.getSelectedRecord() is getting null).

          Comment


            #6
            Sorry, this information is quite useless in terms of being able to help you. All the approaches we've described work and are shown working in samples. If you are having trouble, you need to show code that we can run, so we can see what's going wrong.

            Comment


              #7
              Hi Isomorphic,
              I'm using the latest version "v12.1p_2020-05-06"

              I also came across a similar phenomenon as described in this post.

              I want to display Radio Items in an editable grid, which will always be displayed and not just in "edit mode".
              I followed your instructions and set alwaysShowEditors to be true;


              I can reproduce this with your showcase, based on "customCellEditors" example:
              https://www.smartclient.com/smartcli...tomCellEditors

              This is my code:
              isc.ListGrid.create({
              ID:"countryGrid",
              width:600,
              height:340,
              showAllRecords:true,
              canEdit:true,
              editEvent:"none",
              alwaysShowEditors:true,
              fields:[
              {name:"name", title:"Name", width:"150", canEdit:false},
              {name:"myRadioField", title:"Radio Field", width:"*",
              valueMap: {yes:"Yes",no:"No",askMeLater:"Ask me later"},
              editorType: "RadioGroupItem",
              editorProperties:{
              vertical: false,
              defaultValue: "askMeLater"
              }
              }],
              data:[
              {id:1, name:"row1", myRadioField:"yes"},
              {id:2, name:"row2", myRadioField:"no"},
              {id:3, name:"row3"},
              ]
              });

              and this is the result I get:

              Click image for larger version  Name:	snip_20200508112254.png Views:	0 Size:	31.2 KB ID:	262357

              only when I click on a record and enter "edit mode", I can see the radio group:
              Click image for larger version  Name:	snip_20200508112434.png Views:	0 Size:	39.0 KB ID:	262358

              I'm trying to solve it this way,
              because it seems easier than using RecordComponents

              Can you help?

              Comment


                #8
                Isomorphic, can you please reply to my post?

                Comment


                  #9
                  Sorry for the delay and thanks for the clear test case, that's always what we need to get started on a bug report.

                  We've looked into this and RadioGroupItem definitely doesn't work with alwaysShowEditors as things stand. RadioGroupItem is not technically listed as a supported editor type for alwaysShowEditors, and we mistakenly recommended using them with alwaysShowEditors.

                  Still, there is no major obstacle to making them work in this mode, and we plan to add support for this.

                  However, this is relatively low priority right now, as this is a very rare usage; your post and the OPs - who appears to be a student, perhaps an intern of yours? - are the only attempts we have ever seen to use this functionality.

                  So for now, we'd recommend just using recordComponents to get around the lack of support in alwaysShowEditors mode. Currently our schedule has this officially supported as of 13.0, assuming something more popular & important doesn't bump it!

                  Another approach, which works at least for the binary use case originally asked about, would be to use canToggle with a boolean field, possibly with custom valueIcons if you want an appearance like a radio item.

                  Comment


                    #10
                    Thanks for your response!
                    Yes, I've checked the canToggle option, and it would be great, but I have 3 options in my case so it's not boolean.
                    So..I'll go with the 'recordComponents' approach.

                    Kobi

                    Comment

                    Working...
                    X