/* * 查询方法,查询区域必须用<form></form>包裹住,方便提交服务器处理 * 传入grid的id,that表示查询按钮,传入this即可 */ function search(grid_id,that){ var data = $("#"+grid_id); var queryParams = data.datagrid('options').queryParams; $.each($(that).parent('form').serializeArray(), function() { queryParams[this['name']] = this['value']; }); data.datagrid({ pageNumber: 1 }); }
调用方法:
<form> <span><select name="search[type]" id="order_select_one"> <option value="id">单号</option> <option value="name">名称</option> </select> </span> <span><input name="search[txt_value]" type="text" size="15" /></span> <span> 发布日期:<input type="text" size="20" name="search[date_from]" class="Wdate" onfocus="WdatePicker({dateFmt: 'yyyy-MM-dd HH:mm:ss'})" /> -<input type="text" size="20" name="search[date_to]" class="Wdate" onfocus="WdatePicker({dateFmt: 'yyyy-MM-dd HH:mm:ss'})"/> </span> <input type="button" id="roleBt1" value="查 询" class="order-search-button" onclick="search('dg',this);" /> </form>