bootstrap——疑难杂症总结

1、bootstrapDualListbox的使用

@model MES.Model.T_SYS_TOUNIT
@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <meta charset="utf-8" />
    <link href="~/Content/Bootstrap/css/bootstrap-3.3.7.css" rel="stylesheet" />
    <link href="~/Content/AdminLte/css/AdminLTE.css" rel="stylesheet" />
    <link href="~/Content/Bootstrap/css/bootstrap-duallistbox.css" rel="stylesheet" />
    <link href="~/Content/Select2/css/select2.min.css" rel="stylesheet" />
    <script src="~/scripts/jquery-1.10.2.js"></script>
    <script src="~/Content/Bootstrap/js/jquery.bootstrap-duallistbox.js"></script>
    <script src="~/Content/Select2/js/select2.min.js"></script>
    <title>Merge</title>
    <style>
        .col-md-1, .col-md-2, .col-md-3, .col-md-4, .col-md-5, .col-md-6, .col-md-7, .col-md-8, .col-md-9, .col-md-10, .col-md-11, .col-md-12 {
            float: left;
        }

        .col-md-6 {
            width: 50%;
        }
    </style>
    <script type="text/javascript">
        $(document).ready(function () {
            $("#scrapType").select2({
                language: "zh-CN"
            });

            $.getJSON("/ToUnit/GetMatrixing", function (data) {
                $('#scrapType').html('');
                $('#scrapType').append("<option value=''></option>");
                $.each(data, function (i, item) {
                    $('#scrapType').append("<option value='" + item.ENKEY1 + "'>" + item.ENKEY1 + "</option>");
                });
            });

            $("#scrapType").change(function () {
                document.getElementById("Iframe").src = "/ToUnit/GetMerge?type=" + $('#scrapType').val();
                //$("#bootstrap-duallistbox-nonselected-list_SelectMaterial").html('');
                //$.getJSON("/ToUnit/GetUnitAll", function (data) {
                //    $.each(data, function (i, item) {
                //        $('#bootstrap-duallistbox-nonselected-list_SelectMaterial').append("<option value='" + item.MATERIALID + "'>" + item.MATERIALID + "/" + item.MATERIALNAME + "</option>");
                //    });
                //});

                //demo2.bootstrapDualListbox('refresh');

                //$("#bootstrap-duallistbox-selected-list_SelectMaterial").html('');
                //$.getJSON("/ToUnit/GetMaterialByScrapType?type=" + $("#scrapType").val(), function (data) {
                //    $.each(data, function (i, item) {
                //        $('#bootstrap-duallistbox-selected-list_SelectMaterial').append("<option value='" + item.MATERIALID + "'>" + item.MATERIALID + "/" + item.MATERIALNAME + "</option>");
                //    });
                //});
            });
        });
    </script>
</head>
<body>
    <div class="container ">
        @using (Ajax.BeginForm("SaveMerge", "ToUnit", new AjaxOptions { }, new { @id = "DataForm", @class = "form-horizontal" }))
        {
            <div class="col-sm-6" style="margin-top:10px;float:right;">
                <label>合并换算名称:</label><select name="scrapType" id="scrapType" style="width:150px"></select>
            </div>
            <div class="col-sm-12">
                  <iframe src="/ToUnit/GetMerge?type=" name="Iframe" id="Iframe" width="100%" onload="this.height=Iframe.document.body.scrollHeight"></iframe>
            </div>
            @*<div class="col-sm-12" id="SELECTITEM">
                @Html.ListBox("SelectMaterial", ViewData["lstItem"] as IEnumerable<SelectListItem>, new { @id = "SelectMaterial", @class = "duallistbox input-sm", @multiple = "multiple" })
                <script>
                        var demo2 = $('.duallistbox').bootstrapDualListbox({
                            //nonSelectedListLabel: '可选用户',
                            //selectedListLabel: '已选用户',
                            preserveSelectionOnMove: 'moved',
                            moveOnSelect: true,
                            //nonSelectedFilter: 'ion ([7-9]|[1][0-2])',
                            //infoText: '选中/未选中用户共 {0} 项',
                            //infoTextFiltered: '从 {1} 项 筛选 {0} 项',
                            selectorMinimalHeight: 470,
                            //filterPlaceHolder: '过滤条件',
                            //moveAllLabel: '添加全部',
                            //moveSelectedLabel: '添加选中的',
                            //removeAllLabel: '移除全部',
                            //removeSelectedLabel: '移除选中',
                            //infoTextEmpty: '没有选中用户',
                        });
                </script>
            </div>*@
        }
    </div>
</body>
</html>
@model MES.Model.T_SYS_TOUNIT
@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <meta charset="utf-8" />
    <link href="~/Content/Bootstrap/css/bootstrap-3.3.7.css" rel="stylesheet" />
    <link href="~/Content/AdminLte/css/AdminLTE.css" rel="stylesheet" />
    <link href="~/Content/Bootstrap/css/bootstrap-duallistbox.css" rel="stylesheet" />
    <link href="~/Content/Select2/css/select2.min.css" rel="stylesheet" />
    <script src="~/scripts/jquery-1.10.2.js"></script>
    <script src="~/Content/Bootstrap/js/jquery.bootstrap-duallistbox.js"></script>
    <script src="~/Content/Select2/js/select2.min.js"></script>
    <title>Merge</title>
    <style>
        .col-md-1, .col-md-2, .col-md-3, .col-md-4, .col-md-5, .col-md-6, .col-md-7, .col-md-8, .col-md-9, .col-md-10, .col-md-11, .col-md-12 {
            float: left;
        }

        .col-md-6 {
            width: 50%;
        }
    </style>
</head>
<body>
    <div class="container ">
        <form id="DataIframe" class = "form-horizontal">
            <div class="col-sm-12">
                @Html.ListBox("SelectMaterial", ViewData["lstItem"] as IEnumerable<SelectListItem>, new { @id = "SelectMaterial", @class = "duallistbox input-sm", @multiple = "multiple" })
                <script>
                    var demo2 = $('.duallistbox').bootstrapDualListbox({
                        //nonSelectedListLabel: '可选用户',
                        //selectedListLabel: '已选用户',
                        preserveSelectionOnMove: 'moved',
                        moveOnSelect: true,
                        //nonSelectedFilter: 'ion ([7-9]|[1][0-2])',
                        //infoText: '选中/未选中用户共 {0} 项',
                        //infoTextFiltered: '从 {1} 项 筛选 {0} 项',
                        selectorMinimalHeight: 470,
                        //filterPlaceHolder: '过滤条件',
                        //moveAllLabel: '添加全部',
                        //moveSelectedLabel: '添加选中的',
                        //removeAllLabel: '移除全部',
                        //removeSelectedLabel: '移除选中',
                        //infoTextEmpty: '没有选中用户',
                    });
                </script>
            </div>
        </form>
    </div>
</body>
</html>

 

2、BootstrapTable的checkbox框实现默认全选

{
field: 'state', //id
checkbox: true, //checkbox
align: 'center', //水平对齐方式
valign: 'middle', //垂直对齐方式
formatter: function(value, row, index){
     return {
          checked: true
     }
}

3、BootStrapTable在某一列中动态实现开关按钮

//checkbox框
{
    field: 'status',
    title: '状态',
    formatter: project_status
}

function initSwitch(){
    $('#project_status_switch').bootstrapSwitch({
        onText : "启用",      // 设置ON文本  
        offText : "禁用",    // 设置OFF文本  
        onColor : "success",// 设置ON文本颜色(info/success/warning/danger/primary)  
        offColor : "warning",  // 设置OFF文本颜色 (info/success/warning/danger/primary)  
        size : "small",    // 设置控件大小,从小到大  (mini/small/normal/large)  
        // 当开关状态改变时触发  
        onSwitchChange : function(event, state) {  
            if (state == true) { 
                alert("ON");
            } else {
                alert("OFF");
            }  
         }  
    })
}

//状态栏格式化
function project_status(value, row, index) {
    //var result="";
    //result += "<input type='checkbox' id='project_status'>"
    //return "<div class='switch' id='mySwitch'><input type='checkbox' checked id='project_status_switch' name='mycheck'></div>";
    return "<input type='checkbox' checked id='project_status_switch' name='mycheck'>";
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值