Struts2 中下拉框中採用樹形結構實現
對於產品類別,結構如下:
產品類別(頂級節點:root,型別:product_type):
|-娛樂(產品大類1:product_type1,型別:product_type)
|-音樂(產品分類11,product_type11)
|-流行音樂(子分類111,product_type111)
|-搖滾音樂(子分類112,product_type112)
|-產品分類12
|-商務(產品大類2)
1、資料庫儲存策略
鑑於此,在專案中,對於這樣的需求的實現方法如下:
對於一種類別(例如對於產品類別product_type)的子類別在oss_category(類別表)中儲存方案如下:
1、在oss_category表中插入一條記錄用於標識“產品類別”對應的頂級節點,其
category_id=1,parent_id=-1,category_type=”product_type”,category_name=”root”
2、在oss_category表中插入一條記錄用於標識“product_type11”2級節點,其
category_id=2,parent_id=1,category_type=”product_type”,category_name=”product_type1”
3、在oss_category表中插入一條記錄用於標識“product_type11”3級節點,其
category_id=3,parent_id=2,category_type=”product_type”,category_name=”product_type11”
整個資料庫指令碼如下:
CREATE TABLE `oss_category` (
`category_id` int(11) NOT NULL auto_increment,
`parent_id` int(11) default ‘-1′,
`level` smallint(6) default NULL,
`is_leaf` tinyint(1) default NULL,
`category_title` varchar(100) default NULL,
`category_name` varchar(100) default NULL,
`category_code` varchar(100) default NULL,
`category_type` varchar(30) default NULL,
`image` varchar(255) default NULL,
`status` varchar(20) default NULL,
`creator` varchar(50) default NULL,
`create_date` datetime default NULL,
`modify_user` varchar(50) default NULL,
`modify_date` datetime default NULL,
`description` text,
PRIMARY KEY(`category_id`)
) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=gbk;
INSERT INTO `oss_category` VALUES (’1′, ‘-1′, ’1′, ’0′, ‘root’, ‘root’, ‘root’, ‘product_type’, null, ’1′, null, null, null, null, null);
INSERT INTO `oss_category` VALUES (’2′, ’1′, ’2′, ’0′, ‘<input type=\’checkbox\’ name=\’product_type1\’id=\’product_type1\’/><b>product_type1</b>’, ‘product_type1′, ‘product_type1′, ‘product_type’, null, ’1′, null, null, null, null, null);
INSERT INTO `oss_category` VALUES (’3′, ’1′, ’2′, ’0′, ‘<input type=\’checkbox\’ name=\’product_type2\’ id=\’product_type2\’class=\’treeCheckBox\’/><b>product_typ’, ‘product_type2′, ‘product_type2′, ‘product_type’, null, ’1′, null, null, null, null, null);
INSERT INTO `oss_category` VALUES (’4′, ’3′, ’3′, ’0′, ‘<input type=\’checkbox\’ name=\’product_type21\’id=\’product_type21\’/><b>product_type21</b>’, ‘product_type21′, ‘product_type21′, ‘product_type’, null, ’1′, null, null, null, null, null);
INSERT INTO `oss_category` VALUES (’5′, ’2′, ’3′, ’0′, ‘<input type=\’checkbox\’ name=\’product_type11\’id=\’product_type11\’/><b>product_type11</b>’, ‘product_type11′, ‘product_type11′, ‘product_type’, null, ’1′, null, null, null, null, null);
INSERT INTO `oss_category` VALUES (’6′, ’5′, ’4′, ’1′, ‘<input type=\’checkbox\’ name=\’product_type111\’id=\’product_type111\’/><b>product_type111</b>’, ‘product_type111′, ‘product_type111′, ‘product_type’, null, ’1′, null, null, null, null, null);
INSERT INTO `oss_category` VALUES (’7′, ’3′, ’2′, ’0′, ‘<input type=\’checkbox\’ name=\’product_type22\’ id=\’product_type22\’/><b>product_type22</b>’, ‘product_type22′, ‘product_type22′, ‘product_type’, null, ’1′, null, null, null, null, null);
INSERT INTO `oss_category` VALUES (’8′, ’2′, ’3′, ’0′, ‘<input type=\’checkbox\’ name=\’product_type12\’id=\’product_type12\’/><b>product_type12</b>’, ‘product_type12′, ‘product_type12′, ‘product_type’, null, ’1′, null, null, null, null, null);
INSERT INTO `oss_category` VALUES (’9′, ’4′, ’4′, ’1′, ‘<input type=\’checkbox\’ name=\’product_type211\’id=\’product_type211\’/><b>product_type211</b>’, ‘product_type211′, ‘product_type211′, ‘product_type’, null, ’1′, null, null, null, null, null);
INSERT INTO `oss_category` VALUES (’10′, ’7′, ’4′, ’1′, ‘<input type=\’checkbox\’ name=\’product_type221\’id=\’product_type221\’/><b>product_type221</b>’, ‘product_type221′, ‘product_type221′, ‘product_type’, null, ’1′, null, null, null, null, null);
2、下拉框展現樹形結構策略
為了保證跨瀏覽器的相容性,不採用任何控制元件來實現在下拉框中展現樹形結構,而採用最為原始的拼湊出如下形式的select 框
<select>
<option value=”1″>1</option>
<option value=”11″> |-11</option>
<option value=”12″> |-12</option>
<option value=”2″>2</option>
<option value=”21″> |-21</option>
<option value=”22″> |-22</option>
</select>
也即用 來實現縮排來達到樹形結構的效果,在實現上只需要在程式中拼湊出這樣的字串到介面展現即可。
在Struts2中,採用標籤展現結果時候,注意property的選項escape=”false”,讓Struts2不要對字串進行轉義。
<s:property value=”#request.selectResult” escape=”false”/>
3、程式碼實現
程式碼基本上沿用了原來的樹形結構的程式碼,由於原來與OssCategory及ossCategoryDAO存在衝突,拷貝OssCategory.hbm.xml為Tree.hbm.xml。
3.1、Model層
package com.mobilesoft.framework.tree.model;
import java.util.Date;
import java.util.List;
import java.util.Set;
import com.mobilesoft.framework.common.model.BaseObject;
/**
* OssCategory entity.
*
* @author MyEclipse Persistence Tools
*/
public class Tree extends BaseObject
implements java.io.Serializable {
// Fields
private Integer categoryId;
private Integer parentId;
private Short level;
private Byte isLeaf;
private String categoryTitle;
private String categoryName;
private String categoryCode;
private String categoryType;
private String image;
private String status;
private String creator;
private Date createDate;
private String modifyUser;
private Date modifyDate;
private String description;
private Tree[] childCategories;
// Constructors
/** default constructor */
public Tree() {
}
/** full constructor */
public Tree(Integer parentId, Short level, Byte isLeaf,
String categoryTitle, String categoryName, String categoryCode,
String categoryType, String image, String status, String creator,
Date createDate, String modifyUser, Date modifyDate,
String description) {
this.parentId = parentId;
this.level = level;
this.isLeaf = isLeaf;
this.categoryTitle = categoryTitle;
this.categoryName = categoryName;
this.categoryCode = categoryCode;
this.categoryType = categoryType;
this.image = image;
this.status = status;
this.creator = creator;
this.createDate = createDate;
this.modifyUser = modifyUser;
this.modifyDate = modifyDate;
this.description = description;
}
// Property accessors
public Integer getCategoryId() {
return this.categoryId;
}
public void setCategoryId(Integer categoryId) {
this.categoryId = categoryId;
}
public Integer getParentId() {
return this.parentId;
}
public void setParentId(Integer parentId) {
this.parentId = parentId;
}
public Short getLevel() {
return this.level;
}
public void setLevel(Short level) {
this.level = level;
}
public Byte getIsLeaf() {
return this.isLeaf;
}
public void setIsLeaf(Byte isLeaf) {
this.isLeaf = isLeaf;
}
public String getCategoryTitle() {
return this.categoryTitle;
}
public void setCategoryTitle(String categoryTitle) {
this.categoryTitle = categoryTitle;
}
public String getCategoryName() {
return this.categoryName;
}
public void setCategoryName(String categoryName) {
this.categoryName = categoryName;
}
public String getCategoryCode() {
return this.categoryCode;
}
public void setCategoryCode(String categoryCode) {
this.categoryCode = categoryCode;
}
public String getCategoryType() {
return this.categoryType;
}
public void setCategoryType(String categoryType) {
this.categoryType = categoryType;
}
public String getImage() {
return this.image;
}
public void setImage(String image) {
this.image = image;
}
public String getStatus() {
return this.status;
}
public void setStatus(String status) {
this.status = status;
}
public String getCreator() {
return this.creator;
}
public void setCreator(String creator) {
this.creator = creator;
}
public Date getCreateDate() {
return this.createDate;
}
public void setCreateDate(Date createDate) {
this.createDate = createDate;
}
public String getModifyUser() {
return this.modifyUser;
}
public void setModifyUser(String modifyUser) {
this.modifyUser = modifyUser;
}
public Date getModifyDate() {
return this.modifyDate;
}
public void setModifyDate(Date modifyDate) {
this.modifyDate = modifyDate;
}
public String getDescription() {
return this.description;
}
public void setDescription(String description) {
this.description = description;
}
public Tree[] getChildCategories() {
return childCategories;
}
public void setChildCategories(Tree[] childCategories) {
this.childCategories = childCategories;
}
}
3.2、DAO層
package com.mobilesoft.framework.tree.dao.hibernate;
import org.apache.log4j.Logger;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.LockMode;
import org.springframework.context.ApplicationContext;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
import com.mobilesoft.framework.tree.model.Tree;
/**
* A data access object (DAO) providing persistence and search support for
* Tree entities. Transaction control of the save(), update() and
* delete() operations can directly support Spring container-managed
* transactions or they can be augmented to handle user-managed Spring
* transactions. Each of these methods provides additional information for how
* to configure it for the desired type of transaction control.
*
* @see com.mobilesoft.esales.model.Tree
* @author MyEclipse Persistence Tools
*/
public class TreeDAO extends HibernateDaoSupport {
/**
* Logger for this class
*/
private static final Logger logger = Logger.getLogger(TreeDAO.class);
private static final Log log = LogFactory.getLog(TreeDAO.class);
// property constants
public static final String PARENT_ID = “parentId”;
public static final String LEVEL = “level”;
public static final String IS_LEAF = “isLeaf”;
public static final String tree_TITLE = “categoryTitle”;
public static final String tree_NAME = “categoryName”;
public static final String tree_CODE = “categoryCode”;
public static final String tree_TYPE = “categoryType”;
public static final String IMAGE = “image”;
public static final String STATUS = “status”;
public static final String CREATOR = “creator”;
public static final String MODIFY_USER = “modifyUser”;
public static final String DESCRIPTION = “description”;
public String delimiter;
protected void initDao() {
// do nothing
}
/*
省略掉其他方法
*/
public static TreeDAO getFromApplicationContext(
ApplicationContext ctx) {
return (TreeDAO) ctx.getBean(“treeDAO”);
}
public Tree[] getAlltree() {
ArrayList<Tree> resultList=new ArrayList<Tree>();
String queryString=”from Tree as tree where tree.parentId=1″;
List<Tree> queryList =getHibernateTemplate().find(queryString);
Iterator iterator=queryList.iterator();
while(iterator.hasNext()){
Tree tree=(Tree)iterator.next();
Tree[] childrenArray=getChildCategoriesById(tree.getCategoryId());
logger.debug(“getAlltree() – Tree[] childrenList=” + childrenArray.length);
tree.setChildCategories(childrenArray);
resultList.add(tree);
}
Tree[] resultArray=(Tree[])resultList.toArray(new Tree[resultList.size()]);
return resultArray;
}
public String getChildrenByType(String type,boolean includeRoot,String delimiter ){
this.delimiter=delimiter;
StringBuffer resultBuffer=new StringBuffer();
resultBuffer.append(“<select>”);
StringBuffer queryBuffer=new StringBuffer(“from Tree as tree where tree.categoryType=’”);
queryBuffer.append(type);
queryBuffer.append(“‘ order by tree.categoryId asc “);
logger.fatal(queryBuffer);
List<Tree> queryList =getHibernateTemplate().find(queryBuffer.toString());
if(queryList.size()>0){
Tree[] treeArray=(Tree[])queryList.toArray(new Tree[queryList.size()]);
int start;
if(includeRoot)
start=0;
else
start=1;
resultBuffer.append(“<option value=’”);
resultBuffer.append(treeArray[start].getCategoryId());
resultBuffer.append(“‘>”);
resultBuffer.append(treeArray[start].getCategoryName());
resultBuffer.append(“</option>”);
String childrenStr=getChildCategories4Select(treeArray[start].getCategoryId(),treeArray[start].getLevel());
logger.debug(“getChildrenByType( String ) – start String=” + start +”,level is :”+treeArray[start].getLevel());
resultBuffer.append(childrenStr);
logger.fatal(“getChildrenByType(String) – StringBuffer resultBuffer11111=” + resultBuffer);
resultBuffer.append(“</select>”);
return resultBuffer.toString();
}else{
return “</select>”;
}
}
public Tree[] getChildCategoriesById(int treeId) {
String queryString=”from Tree as tree where tree.parentId=”+treeId;
List<Tree> queryList =getHibernateTemplate().find(queryString);
logger.debug(“getChildCategoriesById(int) – List<Tree> queryList=” + queryList.size());
ArrayList<Tree> resultList=new ArrayList<Tree>();
Iterator iterator=queryList.iterator();
while(iterator.hasNext()){
Tree tree=(Tree)iterator.next();
Tree[] childrenList=getChildCategoriesById(tree.getCategoryId());
logger.debug(“getChildCategoriesById(int) – Tree[] childrenList=” + childrenList+”parentid is “+treeId);
tree.setChildCategories(childrenList);
resultList.add(tree);
}
Tree[] resultArray=(Tree[])resultList.toArray(new Tree[resultList.size()]);
return resultArray;
}
/*
* @return 要拼湊出如下形式的select 框
* <select>
* <option value=”1″>1</option>
* <option value=”11″> |-11</option>
* <option value=”12″> |-12</option>
* <option value=”2″>2</option>
* <option value=”21″> |-21</option>
* <option value=”22″> |-22</option>
* </select>
*
* @param treeId節點的id號
* @param rootLevel所在類別子樹根節點在整棵樹中的層級
*/
public String getChildCategories4Select(int treeId,int rootLevel) {
StringBuffer childBuffer=new StringBuffer();
String queryString=”from Tree as tree where tree.parentId=”+treeId;
List<Tree> queryList =getHibernateTemplate().find(queryString);
logger.debug(“getChildCategories4Select(int,int) – List<Tree> queryList=” + queryList.size());
ArrayList<Tree> resultList=new ArrayList<Tree>();
Iterator iterator=queryList.iterator();
while(iterator.hasNext()){
Tree tree=(Tree)iterator.next();
int childLevel=tree.getLevel();
childBuffer.append(“<option value=’”);
childBuffer.append(tree.getCategoryId());
childBuffer.append(” ‘>”);
for(int i=0;i<=childLevel-rootLevel;i++)
childBuffer.append(“ ”);
childBuffer.append(this.delimiter+tree.getCategoryName());
childBuffer.append(“</option>”);
String childrenStr=getChildCategories4Select(tree.getCategoryId(),rootLevel);
childBuffer.append(childrenStr);
logger.debug(“getChildCategories4Select(int,int) – childBuffer=” + childBuffer);
}
return childBuffer.toString();
}
}
3.3、Service層
TreeService.java
package com.mobilesoft.framework.tree.service;
import java.util.List;
import java.util.Set;
import com.mobilesoft.framework.tree.model.Tree;
public interface TreeService {
/**
* @return 獲取下級子節點
*/
//public Set getChildren(int rootId);
/**
* @return 遞迴指定級別的所有子節點
*
*/
//public Set getChildrenByLevel(int rootId,int level);
/**
* 用於獲取資料字典中指定類別的所有型別的節點,
* 類別表節點的樹形結構
* |– ROOT 根類別(-1)
* |–類別型別:套餐類別 bundle_type
* |–3 套餐類別1
* |–4 套餐類別2
* |–類別型別:產品類別 product_type
* |–產品大類1
* |–產品大類11
* |—產品大類別111
* |—產品大類別112
* |–產品大類12
* @return 獲取指定型別的所有子節點
* 在實現上,對於諸如”產品類別“等下拉框可能為樹形結構的元素,
* 為了避免由於瀏覽器相容性問題,在形式上是樹形結構,
* 實際上就是從字典表(目前樹形結構仍然採用oss_category作為字典表)動態取出資料,然後拼湊成字串形式展現,例如:
* <select>
* <option value=”1″>1</option>
*<option value=”11″> |-11</option>
*<option value=”12″> |-12</option>
*<option value=”2″>2</option>
*<option value=”21″> |-21</option>
*<option value=”22″> |-22</option>
*</select>
* @param type:節點的型別
* @param levle:節點相對於所屬型別的節點的級別 -1表示獲取所屬型別的根節點的所有級別的子節點
*/
public String getChildrenByType( String type);
public String getChildrenByType( String type,boolean includeRoot);
public String getChildrenByType( String type,boolean includeRoot,String delimiter);
/**
* @return 獲取指定根節點的所有子節點
*/
public Tree[]getAllTree();
}
TreeServiceImpl.java
package com.mobilesoft.framework.tree.service.impl;
import java.util.List;
import java.util.Set;
import com.mobilesoft.framework.tree.dao.hibernate.TreeDAO;
import com.mobilesoft.framework.tree.model.Tree;
import com.mobilesoft.framework.tree.service.TreeService;
public class TreeServiceImpl implements TreeService {
TreeDAO treeDAO;
String delimiter;
public Set getChildren(int rootId) {
// TODO Auto-generated method stub
return null;
}
public Set getLevelChildren(int rootId, int level) {
// TODO Auto-generated method stub
return null;
}
public String getChildrenByType( String type){
return treeDAO.getChildrenByType(type,true,this.delimiter);
}
public String getChildrenByType( String type,boolean includeRoot){
return treeDAO.getChildrenByType(type,includeRoot,this.delimiter);
}
public String getChildrenByType( String type,boolean includeRoot,String delimiter){
return treeDAO.getChildrenByType(type,includeRoot,delimiter);
}
public Tree[]getAllTree(){
return treeDAO.getAlltree();
}
public TreeDAO gettreeDAO() {
return treeDAO;
}
public void settreeDAO(TreeDAO treeDAO) {
this.treeDAO = treeDAO;
}
public String getDelimiter() {
return delimiter;
}
public void setDelimiter(String delimiter) {
this.delimiter = delimiter;
}
}
3.4、呼叫方法
以Action中為例:
private TreeService treeService;
public String getChildrenByType(){
String selectResult=treeService.getChildrenByType(“product_type”);
getRequest().setAttribute(“selectResult”, selectResult);
returnSUCCESS;
}
public TreeService getTreeService() {
returntreeService;
}
publicvoid setTreeService(TreeService treeService) {
this.treeService = treeService;
}
注意:getChildrenByType方法有三個過載(overload)方法,
public String getChildrenByType( String type);
public String getChildrenByType( String type,boolean includeRoot);
public String getChildrenByType( String type,boolean includeRoot,String delimiter);
但實際上最後還是呼叫的是getChildrenByType( String type,boolean includeRoot,String delimiter),
引數說明:
type: 類別的型別,例如product_type
includeRoot:是否包含所在類別的根節點,例如查詢product_type是否,是否需要匯出所在類別的root節點
delimiter:在下拉框選擇時候,分隔符型別,預設為“|-”,可以在applicationContext-service.xml中修改或呼叫時候傳遞引數。
3.5、配置檔案
applicationContext-resources.xml
<property name=”mappingResources”>
<list>
<value>com/mobilesoft/framework/tree/model/Tree.hbm.xml</value>
</list>
</property>
applicationContext-dao.xml
<bean id=”treeDAO”
class=”com.mobilesoft.framework.tree.dao.hibernate.TreeDAO”>
<property name=”sessionFactory”>
<ref bean=”sessionFactory” />
</property>
</bean>
applicationContext-service.xml
<bean id=”treeService”
class=”com.mobilesoft.framework.tree.service.impl.TreeServiceImpl”>
<property name=”treeDAO”>
<ref bean=”treeDAO” />
</property>
<property name=”delimiter” value=”|-”/>
</bean>
action-servlet.xml
<bean id=”treeAction” scope=”prototype”
class=”com.mobilesoft.esales.webapp.action.TreeAction”>
<property name=”treeService”>
<ref bean=”treeService” />
</property>
</bean>
struts.xml
<action name=”treeAction” method=”execute” class=”treeAction”>
<result name=”success”>test/treetest.jsp</result>
</action>
相關推薦
Struts2 中下拉框中採用樹形結構實現
在專案中,有大量的諸如“產品型別”這樣的下拉選擇框,為了保證專案後期的可維護性,除了相對固化的類別可以在程式碼中直接寫死外,這些下拉選擇框應當儘量從系統的資料字典表中進行動態讀取和展現。但在展現時候存在一個問題,如果分類存在多級時候,一種方案是採用幾個下拉框進行級聯操作,
easyui中的下拉菜單是樹形結構時如何實現onchange方法
問題 input style 出現 發現 class 如果 box ble 今天碰到一個問題就是我寫的代碼中的一個下拉列表顯示的是樹型菜單,代碼如下(使用的是easyui): .... <tr> <td>地區:</td>
下拉框只顯示最初下拉框中的值和json返回array的交集
sel .text json down emp tno append length drop 首先我們可以遍歷dropdown var array = new Array(); $("#select option").each(function(j){ array[j]=
關於WebDriver中下拉框選項操作 ---- >>Select類的使用:
ui測試 使用 images 如果 lis ima 固定 png 分享圖片 在UI測試的過程中,我們經常會遇到對下拉框的處理, 筆者在日常的維護中, 對下拉框的處理的太多, 各種好定位的不好定位的, 這裏可以分享兩種定位方法: 1.日常定位的方法每個select下
在HTML中的下拉框中怎樣實現超連接?
-h light targe 窗口 ext html中 http com tex 給你個例子自己改吧:<SELECT name="select" onchange="window.open(this.options[this.selectedIndex].value,
angularjs中下拉框select option默認值
edt 工作 ima TP class 匯報 span 說明 pre 1.問題說明: option ng-repeat多空白項 2.解決方案: html: <ion-view hide-nav-bar="true"> <ion-content>
設定下拉框中的選中項
點選設定按鈕下拉框隨機選中 <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="
angularjs中下拉框select 第一個為空白
<label for="userId">發起培訓人</label> <select class="form-control input-sm" ng-model="trainDetail.userId" name="userId" id="
js獲取select下拉框中的值
現在有一id為userType的下拉框,怎麼獲取選中的值: 1 使用者型別: 2 <select name="type" id="userType"> 3 <option value="0">請選擇</option> 4 <option v
JavaScript解決select下拉框中的內容太長顯示不全的問題
分享一下我老師大神的人工智慧教程!零基礎,通俗易懂!http://blog.csdn.net/jiangjunshow 也歡迎大家轉載本篇文章。分享知識,造福人民,實現我們中華民族偉大復興!  
jeestie框架中下拉框select2的用法
使用select2方法是為了使下拉框帶有搜尋選項,方便使用者選擇。使用前就是普通的下拉框,如果下拉的選項很多,你找起來會很費勁,使用select2就可以快速選擇到你想要選擇的選項了。下面將介紹幾個常用的知識。 第一,如何給定普通的下拉框se
selenium python選取下拉框中的值
https://stackoverflow.com/questions/47689936/unable-to-scroll-and-select-desired-year-from-calender-in-webdriver-python Year1990 = driver.find_element_by_
pb編輯視窗控制下拉框中的內容自動篩選並必須選擇正確和欄位型別正確
dw 的 editchanged事件: ib_changed = true cb_update.enabled = true datawindowchild ldwc_dddw datawindowchild ldwc_dddw1 CHOOSE CASE dwo.nam
freemaker中下拉框(動態下拉框和靜態下拉框)的塞值,回顯
靜態下拉,靜態的情況下把所有靜態的可能都列出來,判斷返回的值是否等於option中的值,如果相等就顯示那行,??是判斷不為空: <label class="control-label">所在端:</label>
下拉框中可以實現複選框
(1)要實現的介面形式如下: 下面是jsp頁面中的寫法: <!-- 下面是下拉框中含有複選框。要是能夠傳值,必須重寫easyui——combox,用js新增複選框--> <tr> <td
獲取下拉框中的值
1、下拉選如圖所示,支援模糊查詢,使用的是select2外掛。 2、前臺程式碼如下所示: <td class="title-query">任務狀態:</td> <td class="input-query" nowrap>
ajax非同步請求的list集合,怎麼迴圈新增到select下拉框中?
在jsp頁面中,通過非同步請求,返回的list集合,需要迴圈新增到select下拉框中,如下:$("#fundCode").change(function(){ var fundCode = $(this).val(); var financeAcc = $("#financ
從下拉框中選擇年份和該年的週數,計算出該周的開始日期和結束日期
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <h
IE10中下拉框 title被遮擋以及部分option無法顯示的問題
在IE10和IE11中,選中下拉框最下方的資料項,滑鼠盤旋在下拉框各個選項上,發現選中焦點上方的選項無法提示title;在IE10中option的title容易被下拉框覆蓋。當然這些顯示問題在chro
web自動化測試第12步:selenium中下拉框的解決方法(Select)
在之前,遇到下拉框的時候我們可以用兩次點選來選擇我們需要的選項,不過對於下拉框,我們的webdriver中有封裝的Select包單獨對於下拉框有一套處理的方法,我們可以來學習一下,然後在測試的時候根據不同的情況來選擇需要哪兒種方法。 1.select包方法的使用示例以及定