easyui combobox 实时刷新


使用场景:

A页面以及B页面,A页面有个下拉框,数据是从B页面存在的数据库中获取得到的;现将B页面的数据删除掉,但是在A页面再次点开下拉框时,依旧看到了刚才删除的那条数据;

期望:当B页面已何种方式改变数据库的值时,A页面的下拉框均能实时刷新。

起初不能实现的方法:

1 <td align="right">分类:</td>
2                 <td align="right"><input id="s_typeid"
3                                           data-options="valueField:'typeid',textField:'typename',panelHeight:'150px';url:'/hotspot/questionstype/typelist'"
4                                           style="width: 150px;" class="easyui-combobox"></td>
1 <script>
2    $(function(){
3         $('#s_typeid').combobox({ 
4              url:'/hotspot/questionstype/typelist?t=' + new Date().getTime(),
5              valueField:'typeid',   
6              textField:'typename'  
7     });
8 </script>

 

直接在页面加载完成后,就将下拉框的数据获取到,并赋值给它,于是就出现文章开头的那个问题,后来解决办法:

将HTML中的url属性(第一段代码的绿色部分)去掉,然后使用combobox的onShowPanel方法便可

1   $('#s_typeid').combobox({ 
2             onShowPanel : function(){
3                 var s=$(this).combobox('getData');
4                 $(this).combobox('options').url= '/hotspot/questionstype/typelist?t=' + new Date().getTime();
5                     $(this).combobox('reload');
6             }
7         });  


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM