Radio Buttons basic inline editing in SQLFORM.grid

53 views
Skip to first unread message

Jacob

unread,
Apr 24, 2019, 7:16:56 PM4/24/19
to web2py-users
Hello I'm still new to web2py and I'm currently working on an a grid which utilises basic inline editing using the example from http://www.web2pyslices.com/slice/show/1928/basic-inline-editing-in-sqlformgrid-no-plugin-no-javascript

When I change the options widget to a radio widget for some reason only one value for a whole set of seperate records can be selected rather than each record having only 1 radio button field selected. In other words a record has 4 possible values and they are displayed in a grid and can be edited there is a field with a set which I'm trying to use radio buttons for instead of a drop down menu. When I press a value for the first record this is fine when I move onto the record beneath it the radio button value is selected however the first one becomes empty and this carries on throughout all the records on the grid only 1 field can be selected at a time. If someone could help me please I would be very grateful. 

Dave S

unread,
Apr 25, 2019, 4:58:22 PM4/25/19
to web2py-users


On Wednesday, April 24, 2019 at 4:16:56 PM UTC-7, Jacob wrote:
Hello I'm still new to web2py and I'm currently working on an a grid which utilises basic inline editing using the example from http://www.web2pyslices.com/slice/show/1928/basic-inline-editing-in-sqlformgrid-no-plugin-no-javascript

When I change the options widget to a radio widget for some reason only one value for a whole set of seperate records can be selected rather than each record having only 1 radio button field selected. In other words a record has 4 possible values and they are displayed in a grid and can be edited there is a field with a set which I'm trying to use radio buttons for instead of a drop down menu. When I press a value for the first record this is fine when I move onto the record beneath it the radio button value is selected however the first one becomes empty and this carries on throughout all the records on the grid only 1 field can be selected at a time. If someone could help me please I would be very grateful. 

My first thought is that you've got a bunch of buttons with the same name.  You can check this fairly easily by using your browser's inspect tool, and looking at the buttons for name=.  If that's the case, then you need to work out a way for each item's buttons to get a unique name; perhaps append item.id on the end of the name.

/dps
 

Jacob

unread,
Apr 26, 2019, 10:20:10 PM4/26/19
to web2py-users
Thank you for the response it appears that they do have the same name . I'm sorry I'm still new to programming in general, I've read around about how to use append but I'm failing to understand how it can be applied to the radio widget function which looks like this

  • def radio_widget(field,value,**kwargs):
  • return SQLFORM.widgets.radio.widget(field,value,**kwargs)

Please if you are able to help guide me further I'll be very grateful.

Matthew J Watts

unread,
Jul 24, 2020, 6:08:09 AM7/24/20
to web2py-users
Hi jacob, i am trying to do the same thing, did you find a solution for this?

villas

unread,
Jul 24, 2020, 8:08:45 AM7/24/20
to web2py-users
Are you sure you cannot use ajax?  I think that would be much easier.

Reply all
Reply to author
Forward
0 new messages