jqGrid的搜索框下拉

当需要在jqGrid的搜索框里配置搜索条件时,如下拉,日期等,代码如下:

1      datePick = function(elem)
2      {
3          jQuery(elem).datepicker();4      }
 1         colNames  : [ "OP_ID", "OP_Module", "OP_Type", "OP_Content", "Operator", "OperatorType", "OP_Time", "OP_IP"],
 2         colModel  : [{name:‘op_id‘, index:‘op_id‘, width:100, align:‘center‘, editable:false, search:false},
 3                      {name:‘op_module‘, index:‘op_module‘, width:110, align:‘center‘, search:true, editable:false,
 4                          stype:‘select‘, searchoptions: {dataUrl:‘./select/module‘, sopt:[‘eq‘, ‘ne‘]}},
 5                      {name:‘op_type‘, index:‘op_type‘, width:100, align:‘center‘, search:true, editable:false,
 6                          stype:‘select‘, searchoptions: {dataUrl:‘./select/type‘, sopt:[‘eq‘, ‘ne‘]}},
 7                      {name:‘op_content‘, index:‘op_content‘,  width:250, align:‘center‘, editable:false, sortable:false,
 8                          stype:‘text‘, searchoptions: {sopt:[‘bw‘, ‘bn‘, ‘ew‘, ‘en‘,‘cn‘, ‘nc‘]}},
 9                      {name:‘op_by‘, index:‘op_by‘, width:100, align:‘center‘, search:true, editable:false},
10                      {name:‘operator_type‘, index:‘operator_type‘, width:130, search:true, align:‘center‘, editable:false,
11                          stype:‘select‘, searchoptions: {dataUrl:‘./select/operator_type‘, sopt:[‘eq‘, ‘ne‘]}},
12                      {name:‘op_at‘, index:‘op_at‘, width:170, align:‘center‘, search:true, editable:false,
13                          stype:‘text‘, searchoptions: {dataInit:datePick, attr:{title:‘Select Date‘}, sopt:[‘cn‘, ‘nc‘, ‘in‘, ‘ni‘]}, formatter:‘date‘, formatoptions:{srcformat: ‘Y-m-d H:i:s‘, newformat: ‘m/d/Y  H:i:s‘}},
14                      {name:‘op_ip‘, index:‘op_ip‘, width:100, align:‘center‘, search:true, editable:false}
15                     ],

其中,colModel的属性的stype有“text”和“select”两种,需要下拉选项时,则选择“select”;同时,searchoptions也进行设置,dataUrl为请求路由,路由返回的数据是

<select><option>1</option></select>的格式;重要的是需设定:ajaxSelectOptions: {type: "GET"} ,其中type可以是Post,这样你的搜索才能返回数据。

1     jQuery(grid_selector).jqGrid({
2         url                : "./show_log",
3         datatype           : "json",
4         mtype             : "post",
5         height            : 370,
6         width             : 1150,
7         ajaxSelectOptions : {type: "GET"} ,

而想显示日期选择框时,stype设定为“type”,searchoptions: {dataInit:datePick, attr:{title:‘Select Date‘}, sopt:[‘cn‘, ‘nc‘, ‘in‘, ‘ni‘]},

formatter:‘date‘, formatoptions:{srcformat: ‘Y-m-d H:i:s‘, newformat: ‘m/d/Y H:i:s‘}}。其中,formatoptions可以自己设置需要的格式。

时间: 2024-08-02 22:17:44

jqGrid的搜索框下拉的相关文章

360浏览器搜索框下拉选择图片js模拟select效果

最近360浏览器网址导航的主页增加了一个下拉选择图片搜索的功能,也就是用js模拟出了select的效果,今天在单位闲了无事干,就把空上功能给摸索出来了,虽然做的不是太完善,但对要求不高的用户来说,已经可以了,而且也可以为学习Js的朋友提供参考. <html> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8"> <style>

行内表单 在统一行显示搜索框 下拉框 按钮

05===> 在同一行显示 搜索表单 下拉框表单 搜索按钮 清空按钮 使用了[行内表单] inline 属性可以让表单域变为行内的表单域 (让表单显示在同一行) <el-form ref="formInline" :inline="true" :model="formInline" class="demo-form-inline"></el-form> demo-form-inline是自带的 f

饿了么 顶部搜索框下拉动画小效果

效果描述:当下拉的时候渐变产生对固定的搜索框 import React, { Component } from "react"; import { connect } from "react-redux"; import { Container, Header, Title, Content, Button, Icon, Left, Right, Body, FlatList, } from "native-base"; import { Dim

自定义SWT控件三之搜索功能下拉框

3.搜索功能下拉弹出框 package com.view.control.select; import java.util.ArrayList; import java.util.LinkedList; import java.util.List; import log.HikLog; import org.apache.commons.lang3.StringUtils; import org.eclipse.swt.SWT; import org.eclipse.swt.custom.CLa

JavaScript---网络编程(11)--DHTML技术演示(4)-单选框/下拉菜单/添加文件

本节讲述单选框/下拉菜单/添加文件,综合css,html和JavaScript. 单选框: 实现的功能是:(类似平时的性格测试) 先隐藏一部分页面,然后通过点击单选框来显示. 再通过选项的选择-(每个选项有不同的积分)积分的多少来给出评语 演示代码: <html> <head> <title>DHTML技术演示---radio的使用</title> <meta http-equiv="content-Type" content=&q

UI中经常出现的下拉框下拉自动筛选效果的实现

小需求是当你在第一个下拉框选择了国家时,会自动更新第二个省份的下拉框,效果如下 两个下拉选择Html如下: <select id="country_select"> <option> All Countries</option> <option> Afghanistan</option> <option> Albania</option> <option> Algeria</optio

iOS快速集成搜索界面下拉菜单框架

前言 这次推出的控件,比较常用,搜索界面下拉菜单,如果喜欢我的文章,可以关注我微博:吖了个峥,也可以来小码哥,了解下我们的iOS培训课程.后续还会更新更多内容,有任何问题,欢迎简书留言峥吖... Demo效果: 效果图.gif Demo演示: 1.创建下拉菜单 YZPullDownMenu *menu = [[YZPullDownMenu alloc] init]; menu.frame = CGRectMake(0, 20, YZScreenW, 44); [self.view addSubv

UI自动化之特殊处理二(弹框\下拉框\选项\文件上传)

弹框\下拉框\选项\文件上传也是一些比较特殊的操作 目录 1.弹框 2.下拉框 3.选项 4.文件上传 1.弹框 弹框有三种形式,value为alert.confirm.prompt三种的弹框,第一个仅可点击确认,第二个可点击取消和确认,第三个可以输入内容再点击取消或者确认 alert:仅需要定位到alert上,然后再确认 m= driver.switch_to_alert() m.accept() confirm:定位到alert,点击取消或者确认 m= driver.switch_to_al

百度搜索设置下拉框的操作

Selenium Webdriver百度搜索设置,代码参照虫师selenium_webdriver(python)第一版中百度搜索框设置的代码 #coding:utf-8 from selenium import webdriver import time dr=webdriver.Ie() dr.get("http://www.baidu.com") dr.find_element_by_link_text("设置").click() #定位父节点后再定位子节点