【问题标题】:Programmatically filling combo-boxes in BootstrapTable以编程方式填充 BootstrapTable 中的组合框
【发布时间】:2018-11-07 20:52:02
【问题描述】:

我在 Bootstrap V4 和 jsp 中成功使用了 BootstrapTable 的服务器端选项

  <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()%>",

目前,“状态”组合框填充了 BootstrapTable “看到”的数据。 (即用户在表格中导航的次数越多,组合框将包含的值越多)

如何以编程方式使用预定义值列表设置“状态”组合框?

【问题讨论】:

    标签: twitter-bootstrap jsp bootstrap-4 server-side bootstrap-table


    【解决方案1】:

    “hack”解决方案是直接通过 jquery 访问下拉列表

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

    (将“状态”替换为所需列标题的名称)

    这样就可以了

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

    (或其他)

    我希望有更优雅的东西,也许使用引导表的方法

    【讨论】:

      猜你喜欢
      • 2012-09-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-12-13
      • 1970-01-01
      • 2010-09-08
      相关资源
      最近更新 更多