如何在数据表中的select选项中使列visibilty为true

时间:2017-01-27 12:38:28

标签: jquery datatables

当我选择生成(Pending_Flag == 1)时,第15列的下拉(ViewPkr)可见性的compelete(Pending_Flag == 2)选项应该是真的,点击按钮"#GoBtn" 另一方面,对于第15列的待定(Pending_Flag == 0)选项可见性的选择应该是点击按钮"#GoBtn"



//button code 
$(document).ready(function() {
  $("#GoBtn").click(function() {

    Pending_Flag = $("#ViewPkr option:selected").val();

    if (Pending_Flag == 1) {
      StatusChecker = 1;
    }
    GetDocList(SelectedRTA, Pending_Flag, Pending_Flag);
    if (Pending_Flag == 0) {

    }
    if (Pending_Flag == 1) {

      DT_DocList_Table.columns([15]).visible(true);
    }
    if (Pending_Flag == 2) {

      DT_DocList_Table.columns([15]).visible(true);
    }
  });
});
// datatable structure
function CreateDatatable(ScreenStage) {
  $("#DocTableDiv").empty();
  var str = '<table class="display table table-hover table-striped dataTable no-footer" id="DocListTable" width="100%"></table>';
  $("#DocTableDiv").append(str);

  DT_DocList_Table = $("#DocListTable").dataTable({
    "data": ListJsonData,
    //"aaSorting": [[1, "desc"]],
    "order": [
      [1, "desc"]
    ],
    "sDom": 'CTfr<"clear">tip',
    //        "sDom": 'lC<"H"Tfr>t<"F"p>',
    "dom": 'CT<"clear">t<"bottom"p>',
    "language": {
      "sSearch": ""
    },
    "columnDefs": [

      {
        "targets": 14 "title": "sampledata",

      }, {
        "targets": 15,
        "title": "Redo",
        "render": function(data) {
          var returnHTML1 = CreateButton(data);
          return returnHTML1;
        },
        "sortable": true,
        "className": "col-xs-1"
      }


      , {
        "visible": false,
        "targets": [15]
      }
    ]
  });
  $('.dataTables_filter input[type="search"]').attr('placeholder', 'Search')
}
&#13;
<select class="selectpicker" data-live-search="true" data-size="3" id="ViewPkr">
  <option value="0">Pending</option>
  <option value="1">Generated</option>
  <option value="2">Completed</option>
</select>
&#13;
&#13;
&#13;

0 个答案:

没有答案