以编程方式填充BootstrapTable中的组合框 [英] Programmatically filling combo-boxes in BootstrapTable

查看:109
本文介绍了以编程方式填充BootstrapTable中的组合框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已成功将BootstrapTable的服务器端选项与Bootstrap V4和jsp结合使用

I am successfully using the server-side option of BootstrapTable with Bootstrap V4 and jsp

  <table class="table table-condensed table-bordered table-hover" id="position-list"
    data-toggle="table"
    data-url="/pages/positions/p_getRows.jsp"
    data-side-pagination="server"
    data-filter-control="true"
    data-pagination="true" 
    data-click-to-select="true"
    data-id-field="id"
    data-page-list="[10, 25, 50, 100, ALL]"
    data-show-footer="false"   
    data-minimum-count-columns="2"                           
    data-pagination="true"                           
    >
    <thead>
       <tr>
          <th data-sortable="true" data-field="Status" data-filter-control="select">Status</th>
          ...
       </tr>
    </thead>
    <tbody>
    </tbody>
  </table>

这是p_getRows.jsp ajax

int fromPos=SecurityIssues.StringToInt(request.getParameter("offset"));
int limit=SecurityIssues.StringToInt(request.getParameter("limit"));

//simplified for illustration purposes
String sqlQuery="SELECT * from (select *,row_number() over (order by position_no) as RowNum from ("+...sql for all positions...+")b )  a where a.rowNum between "+fromPos+" and "+(fromPos+limit);
int numPos=...//number of total positions
%>
{
   "total":<%=numPos%>,
    "rows":[   

<% 
for (Row r:listRows) {%>

    {
        "Status":"<%=r.getStatus()%>",

此刻,状态"(Status)组合框填充有BootstrapTable看到"的数据. (即,用户在表格中浏览的次数越多,组合框将包含的值越多)

At the moment, the "Status" combo-box is populated with the data that BootstrapTable "sees". (I.e. the more the user navigates within the table, the more values the combo-box will contain)

如何通过编程方式设置带有预定义值列表的状态"组合框?

How do I programmatically set the "Status" combo-box with a list of pre-defined values?

推荐答案

黑客"解决方案是直接通过jquery访问下拉列表

A "hack" solution is to access the dropdown directly via jquery

$('.form-control.bootstrap-table-filter-control-status')

(用所需列标题的名称替换状态")

(replacing 'status' with the name of the desired column header)

然后可以做

 $('.form-control.bootstrap-table-filter-control-status').html('
<OPTION value="A">A</OPTION><OPTION value="B">B</OPTION>');

(或其他)

我希望可以使用引导表的方法来获得更优雅的效果

I was hoping for something more elegant, perhaps using the methods of the bootstrap table

这篇关于以编程方式填充BootstrapTable中的组合框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆