@model string

<div class="main">
    <div class="control-group clearfix">
        <div class="btn-group left">
            <button type="button" class="btn btn-default btn-sm ui-selectInvert">反选</button>
            <button type="button" class="btn btn-default btn-sm sure">确定</button>
        </div>
    </div>
    <span class="help-block"></span>
    <table border=0 cellpadding=0 cellspacing=0 width=100% class="table table-bordered" id="tb_list">
        <thead><tr>
            <td align="center"  style="width:40px">选择</td>
            <td align="left">用户名</td>
        </tr>
        <tr class="item" id="item_{id}">
            <td align="center"  style="width:40px">
                <input type="checkbox" id="id" name="id" class="ui-convertTextById Member" data-custom-params="url:'@Url.Action("GetFieldByIds", "Member")',textField:'username'" value="{owner_uid}">
            </td>
            <td align="left" class="owner">
                <span class="ui-convertTextById Member1" data-custom-params="url:'@Url.Action("GetFieldByIds", "Member")',textField:'username'">{owner_uid}</span>
            </td>
        </tr>
    </table>
</div>
<script>
    function LoadData()
    {
        var url = "@Url.Action("PageListData", "Friends")"
        $("#tb_list").ListBind(url, {callBack: "LoadedInit" });
        ConvertText($(".Member"));
        ConvertText($(".Member1"));

        $(function () {
            parent_owner = parent.$("#receiver");
            $item = $(".item");
            $(".sure").click(function () {
                parent_owner.val(Values($item))
                CloseDialog();
            })
            if (parent_owner.val() != "") {
                identicalId($item, parent_owner.val());
            }
        })
    }

    LoadData();


    function Values(obj) {//获取value
        var str = "";
        obj.each(function (j) {
            if ($(this).find("input").is(":checked")) {
                str += $(this).find("input:checked").val();
                str += ",";
            }
        })
        str = str.substring(0, str.length - 1)
        return str;
    }
    function identicalId(obj, values) {//已加入表单的默认选中
        var str = values.split(",");
        obj.each(function (w) {
            var $this_val = $(this).find("input").val();
            for (var q = 0; q < str.length; q++) {
                if (str[q] == $this_val) {
                    $(this).find("input").attr({ "checked": "checked" });
                }
            }
        });
    }
</script>
