EasyUI Forum
May 01, 2024, 11:06:13 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Load Form doesn't check radiobutton  (Read 2779 times)
poeziafree
Jr. Member
**
Posts: 69


View Profile Email
« on: October 05, 2022, 07:19:19 AM »

Hello,

form('load', {}); doesn't check the radiobutton.

How can I achieve this?

I have two radiobuttons with the same name each having its own label (see the screen below), like Gender: a) male b) female
Logged
jarry
Administrator
Hero Member
*****
Posts: 2262


View Profile Email
« Reply #1 on: October 05, 2022, 09:11:26 PM »

Please look at this example. It works fine.
Code:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Load Form Data - jQuery EasyUI Demo</title>
<link rel="stylesheet" type="text/css" href="https://www.jeasyui.com/easyui/themes/default/easyui.css">
<link rel="stylesheet" type="text/css" href="https://www.jeasyui.com/easyui/themes/icon.css">
<script type="text/javascript" src="https://www.jeasyui.com/easyui/jquery.min.js"></script>
<script type="text/javascript" src="https://www.jeasyui.com/easyui/jquery.easyui.min.js"></script>
<script type="text/javascript">
$(function(){
$('#ff').form('load',{
gender:'male',
name:'myname',
email:'mymail@gmail.com',
subject:'subject'
});
})
</script>
</head>
<body>
<h2>Load Form Data</h2>
<div class="easyui-panel" title="New Topic" style="width:100%;max-width:500px;padding:30px 60px;">
<form id="ff" method="post">
<div style="margin-bottom:20px">
<label class="textbox-label textbox-label-before">Gender:</label>
<input class="easyui-radiobutton" name="gender" data-options="label:'female',labelPosition:'after',value:'female'">
<input class="easyui-radiobutton" name="gender" data-options="label:'male',labelPosition:'after',value:'male'">
</div>
<div style="margin-bottom:20px">
<input class="easyui-textbox" name="name" style="width:100%" data-options="label:'Name:',required:true">
</div>
<div style="margin-bottom:20px">
<input class="easyui-textbox" name="email" style="width:100%" data-options="label:'Email:',required:true,validType:'email'">
</div>
<div style="margin-bottom:20px">
<input class="easyui-textbox" name="subject" style="width:100%" data-options="label:'Subject:',required:true">
</div>
</form>
</div>
</body>
</html>
Logged
poeziafree
Jr. Member
**
Posts: 69


View Profile Email
« Reply #2 on: October 05, 2022, 10:25:52 PM »

Jarry, thank you as always!

Could you please help us extend the radiobutton functionality so that it supports not only a single radiobutton, but a group of radiobuttons aligned either horizontally, or vertically, each radiobutton having its own label, while the group itself may have a single label?

That would be very good for the entire project.

Reference: https://examples.sencha.com/extjs/7.5.1/examples/kitchensink/?modern#form-radiogroup

Thanks
Logged
jarry
Administrator
Hero Member
*****
Posts: 2262


View Profile Email
« Reply #3 on: October 10, 2022, 05:19:19 AM »

Please refer to this example https://www.jeasyui.com/demo/main/index.php?plugin=RadioGroup&theme=material-teal&dir=ltr&pitem=&sort=asc
Logged
poeziafree
Jr. Member
**
Posts: 69


View Profile Email
« Reply #4 on: October 11, 2022, 01:02:42 PM »

Thanks, Jarry!

Awesome features, indeed!


There is just one detail missing: the group should have the parent label, shouldn't it? Otherwise, when used in forms, the radiogroup shows misaligned without a parent label.

See the example screenshot below (I have circled the parent label):

Logged
jarry
Administrator
Hero Member
*****
Posts: 2262


View Profile Email
« Reply #5 on: October 11, 2022, 08:15:22 PM »

This code shows how to add a label to the radiogroup.
Code:
<form id="ff">
<div class="f-row" style="margin-bottom:20px">
<div style="margin:10px 20px 0 0">RadioLabel:</div>
<div class="easyui-radiogroup" data-options="
name:'radio2',dir:'v',
data:[{value:'1',label:'Item1'},{value:'2',label:'Item2'},{value:'3',label:'Item3'}],
itemStyle:{height:40}
"></div>
</div>
</form>
Logged
poeziafree
Jr. Member
**
Posts: 69


View Profile Email
« Reply #6 on: October 15, 2022, 01:36:05 AM »

Hi, Jarry!

Thank you again!

Does validation work on radiogroup?

I noticed that required: true doesn't work, for example.

Also, $('#gender').radiogroup('enable'); OR $('#gender').radiogroup('disable'); doesn't work too.

Please, help.
Logged
kimmansu
Newbie
*
Posts: 4


View Profile Email
« Reply #7 on: December 22, 2023, 12:57:20 AM »


https://www.jeasyui.com/forum/index.php?topic=8784.msg23427#msg23427
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!