Dojo widgets introduction and sample code (1)

Checkboxes

 

Checkboxes are used when there are multiple lists of options and user may select any number of choices, including zero, one, or more. Each checkbox is independent of all other checkboxes in the list, so checking one box doesn't uncheck the others.

C heck boxes are the same as html but dojo provides more controls and styling options than a conventional check box. The checkbox contains Boolean types value either 'true ' or 'false '. The following example creates a Checkbox:

 

Here is the code of Program:

<html>
   <head>
     <title>checkbox</title>
     <!-- check box -->
     <script type= "text/javascript" >
       dojo.require ( "dojo.parser" ) ;
       dojo.require ( "dijit.form.CheckBox" ) ;
     </script>
   </head>

   <body>
     <h2>Check box</h2>
     <input id= "cb"  dojotype= "dijit.form.CheckBox"  name= "developer" 
                           checked=
"checked"  value= "on" type= "checkbox"  />
     <label  for = "cb" > Are you a Developer </label> 
   </body>
</html>

 

Radio buttons

The RadioButton class is declared in the CheckBox.js file , hence you need dojo.require(dijit.form.CheckBox) for RadioButtons to work.

Radio buttons are used when there is a list of two or more options that are mutually exclusive and the user must select exactly only one choice from a group of radio button. Click a non-selected radio button will deselect whatever other button was previously selected in the list.

 

Radio Buttons are the same as html but dojo provides more controls and styling options than a conventional Radio button. The radio button also contains Boolean types value either 'true ' or 'false '. The following example creates a Radio buttons:

Here is the code of Program:

<html>
   <head>
     <title>Radio</title>
     <!-- radio -->
     <script type= "text/javascript" >
       dojo.require ( "dojo.parser" ) ;
       dojo.require ( "dijit.form.*" ) ;
     </script>
   </head>

   <body>
     <h2>Radio button</h2>
     <input dojoType= "dijit.form.RadioButton"  id= "val1"  name= "group1" 
          checked=
"checked"  value= "Programmer"  type= "radio"  />
     <label  for = "val1" > Programmer </label>
     <input dojotype= "dijit.form.RadioButton"  id= "val2"   name= "group1" 
           
value= "Designer"  type= "radio"  />
     <label  for = "val2" > Designer </label>
     <input dojotype= "dijit.form.RadioButton"  id= "val3"   name= "group1" 
                      
value= "Developer"  type= "radio"  />
     <label  for = "val3" > Developer </label> 
   </body>
</html>

 

Combo Box:

A combo box is a graphical user interface that controls GUI element. It is a combination of a drop-down list or list box and a single-line textbox

, allowing the user either to type a value directly into the control or choose from the list of options.

 

Here is the code of Program:

<html>
   <head>
     <title>combobox</title>
     <!-- combo box -->
     <script type= "text/javascript" >
       dojo.require ( "dojo.parser" ) ;
       dojo.require ( "dijit.form.ComboBox" ) ;
      
       function setVal1 ( value ) {
         console.debug ( "Selected " +value ) ;
       }
     </script>
   </head>

   <body>
     <h2>Combo box</h2>
     <select name= "country"  dojoType= "dijit.form.ComboBox"
        autocomplete= "false"  value= "country"
     
onChange= "setVal1" >
       <option>India</option>
       <option>California</option>
       <option >Illinois</option>
       <option >New York</option>
       <option >Texas</option>
     </select>
   </body>
</html>

 

Auto Completer:

The Auto Completer provides the front-end logic for text-entry suggestion and completion functionality. The features of the auto completer to control navigation of the suggestions container via up/down arrow keys and rich event model . Easily to configure its included parameters and custom formatting of auto completer suggestions, query delimiters (Multiple selections per input box), configurable query delay, type-ahead, animation of suggestions container, built-in query caching and much more.

The Combo Box is a hybrid between the combo box and text field. It provides a list of acceptable values. This is good for open-ended multiple choice questions.  Rather than having two fields - a combo box and an Other text box - you can use just one field.

 

Here is the code of Program:

<html>
   <head>
     <title>Auto Completer Combo</title>
       <style type= "text/css" >
         @import  "../resources/dojo.css" ;
         @import  "../dijit/themes/tundra/tundra.css" ;
       </style>

       <script type= "text/javascript"  src= "dojo.xd.js"
         djConfig= "parseOnLoad: true" ></script>

       <!-- combo box -->
       <script type= "text/javascript" >
         dojo.require ( "dojo.parser" ) ;
         dojo.require ( "dijit.form.FilteringSelect" ) ;
       </script>
   </head>

   <body  class = "tundra" >
     <h2>Auto Completer Combo box</h2>
     <select dojoType= "dijit.form.FilteringSelect"  name= "sname" 
     autocomplete= "false"  value= "Vinod" >
       <option value= "Vinod" >Vinod</option>
       <option value= "Vikash"  >Vikash</option>
       <option value= "Deepak"  >Deepak</option>
       <option value= "DeepakSir"  >Deepak Sir</option>
       <option value= "Arun"  >Arun</option>
       <option value= "Amar"  >Amar</option>
       <option value= "Aman"  >Aman</option>
     </select>
   </body>
</html>

 

 

InlineEditBox

InlineEditBox describes a widget wrapper that takes a child widget declared in markup and makes it inline-editable. This widget performs the role as a <div> tag when not in edit mode. When you click widget text then it open as an editable mode. In this mode, you edit the text and save it. Whenever you don't save the editable text then it can't be save so, after editing the text you must have to save it. Without editing text you can't be save it.

 

Here is the code of Program:

<html>
<head>
<title>InlineEdit Demo</title>
     <style type= "text/css" >
       @import  "../resources/dojo.css" ;
       @import  "../dijit/themes/tundra/tundra.css" ;
      
   </style>

     <script type= "text/javascript"  src= "dojo.xd.js" 
     djConfig= "parseOnLoad: true" ></script>

     <script type= "text/javascript" >
        dojo.require ( "dojo.parser" ) ;
        dojo.require ( "dijit.form.InlineEditBox" ) ;
        dojo.require ( "dijit.form.Textarea" ) ;
      </script>
</head>
   <body>
   Edit Please:<br>
     <p id= "areaEditable"  dojoType= "dijit.form.InlineEditBox"
       renderAsHtml= "true"  autoSave= "false" >
       <textarea dojoType= "dijit.form.Textarea" >
         vinod
       </textarea>
     </p>   
   </body>

 

The following code is the InlineEditBox that edits date of dijit.form.DateTextBox save it automatically. The inner textarea tag is the Textarea widget . When a user run this code then they see the paragraph of rich text. If user clicks the text, the plain text appears in paragraph. If you want to change the value then click the date text and select the appears date.

The InlineEditBox has methods get/setDisplayedValue , inline. The following code shows the DateTextBox that makes inline in HTML

Here is the code of program: 

<html>

<head>
   <title>InlineEdit Date Demo</title>
  
   <style type= "text/css" >
       @import  "../resources/dojo.css" ;
       @import  "../dijit/themes/tundra/tundra.css" ;
      
   </style>

     <script type= "text/javascript"  src= "dojo.xd.js" 
      djConfig= "parseOnLoad: true" ></script>

     <script type= "text/javascript" >
        dojo.require ( "dojo.parser" ) ;
        dojo.require ( "dijit.form.InlineEditBox" ) ;
        dojo.require ( "dijit.form.DateTextBox" ) ;
      </script>

</head>
   <body  class = "tundra" >
     <p id= "backgroundArea"  dojoType= "dijit.form.InlineEditBox"  >
     <input name= "date"  value= "2005-12-30"  dojoType= "dijit.form.DateTextBox"
               constraints= { datePattern: ' MM/dd/yy '}
               lang= "en-us"
               required= "true"
               promptMessage= "mm/dd/yy"
               invalidMessage= "Invalid date. Please use mm/dd/yy format." >
   </body>
</html>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
SQLAlchemy 是一个 SQL 工具包和对象关系映射(ORM)库,用于 Python 编程语言。它提供了一个高级的 SQL 工具和对象关系映射工具,允许开发者以 Python 类和对象的形式操作数据库,而无需编写大量的 SQL 语句。SQLAlchemy 建立在 DBAPI 之上,支持多种数据库后端,如 SQLite, MySQL, PostgreSQL 等。 SQLAlchemy 的核心功能: 对象关系映射(ORM): SQLAlchemy 允许开发者使用 Python 类来表示数据库表,使用类的实例表示表中的行。 开发者可以定义类之间的关系(如一对多、多对多),SQLAlchemy 会自动处理这些关系在数据库中的映射。 通过 ORM,开发者可以像操作 Python 对象一样操作数据库,这大大简化了数据库操作的复杂性。 表达式语言: SQLAlchemy 提供了一个丰富的 SQL 表达式语言,允许开发者以 Python 表达式的方式编写复杂的 SQL 查询。 表达式语言提供了对 SQL 语句的灵活控制,同时保持了代码的可读性和可维护性。 数据库引擎和连接池: SQLAlchemy 支持多种数据库后端,并且为每种后端提供了对应的数据库引擎。 它还提供了连接池管理功能,以优化数据库连接的创建、使用和释放。 会话管理: SQLAlchemy 使用会话(Session)来管理对象的持久化状态。 会话提供了一个工作单元(unit of work)和身份映射(identity map)的概念,使得对象的状态管理和查询更加高效。 事件系统: SQLAlchemy 提供了一个事件系统,允许开发者在 ORM 的各个生命周期阶段插入自定义的钩子函数。 这使得开发者可以在对象加载、修改、删除等操作时执行额外的逻辑。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值