国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > JavaScript > 正文

使用Easyui實現(xiàn)查詢條件的后端傳遞并自動刷新表格的兩種方法

2019-11-19 10:51:09
字體:
供稿:網(wǎng)友

搜索框如下:

  • 通過datagrid的load方法直接傳遞參數(shù)并自動刷新表格
  • 通過ajax的post函數(shù)傳遞參數(shù)并通過loadData方法將數(shù)據(jù)初始化到表格中

js代碼(搜索按鈕的點擊事件部分):

$("#standardQueryBtn").click(function(){//點擊搜索按鈕的觸發(fā)事件      if($("#offerid").val() != ""){//判斷id搜索框的值是否為空        $("#dg").datagrid('load',{//調(diào)用load方法傳遞參數(shù),從服務(wù)器加載新數(shù)據(jù)          "offer.id":$("#offerid").val(),//將搜索框的值賦給offer.id并傳到后端          "flag":'qid',//傳遞一個flag值用于判斷執(zhí)行何種操作          });          }else if($("#offername").val() != ""){//判斷name搜素框的值是否為空          $.post("${pageContext.request.contextPath}/OfferServlet",//通過ajax的post函數(shù)傳遞flag和offername值              {flag:"qname","offer.name":$("#offername").val()},              function(ons){//回調(diào)函數(shù)處理                var json = JSON.parse(ons);//將返回的字符串轉(zhuǎn)換為JSON                $('#dg').datagrid('loadData',json);//將表格數(shù)據(jù)初始化方式更新              });        }          });

jsp代碼(只包含按鈕和搜索框的toolbar):

 <div id="toolbar">    <a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" class="easyui-linkbutton" iconCls="icon-add" plain="true" onclick="newOffer()">新增商品</a>    <a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" class="easyui-linkbutton" iconCls="icon-edit" plain="true" onclick="editOffer()">編輯商品</a>    <a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" class="easyui-linkbutton" iconCls="icon-remove" plain="true" onclick="destroyOffer()">刪除商品</a><br>    商品ID:<input type="text" name="offer.id" id="offerid" />     商品名稱:<input type="text" id="offername"/>     <a id="standardQueryBtn" href="javascript:void(0)" rel="external nofollow" class="easyui-linkbutton" data-options="iconCls:'icon-search'">搜索</a>   </div>

總結(jié)

以上所述是小編給大家介紹的使用Easyui實現(xiàn)查詢條件的后端傳遞并自動刷新表格的兩種方法,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復(fù)大家的。在此也非常感謝大家對武林網(wǎng)網(wǎng)站的支持!
如果你覺得本文對你有幫助,歡迎轉(zhuǎn)載,煩請注明出處,謝謝!

發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 栖霞市| 辽宁省| 青神县| 于都县| 兴和县| 湘阴县| 怀仁县| 利川市| 汕头市| 南漳县| 福建省| 灵宝市| 枣庄市| 都昌县| 卢湾区| 宁武县| 湘西| 信宜市| 喜德县| 华安县| 宁河县| 通榆县| 綦江县| 临颍县| 合江县| 铜梁县| 永胜县| 清苑县| 全椒县| 电白县| 油尖旺区| 遂川县| 永顺县| 新化县| 随州市| 河南省| 新晃| 怀化市| 新野县| 昌黎县| 榕江县|