<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<dynamic>" %>
<table id="dgRoomModalBY" class="easyui-datagrid" style="width: 100%; height: auto;"
    data-options="
			url: '/RoomType/LoadRoomTypeModalsBY/',
			queryParams: { roomTypeID: <%: Model %>,deviceType:1},
			toolbar: '#tbRelationDeviceBY',
			border: false,
			singleSelect: true,
			checkOnSelect: true,
			selectOnCheck: true,
			pagination: false,
			pageSize: 50,
			rownumbers: true,
			striped: true,
			sortName: 'Sort',
			sortOrder: 'asc',
			fit: true,
			fitColumns: true,
			idField: 'ID',
			method: 'POST',
			onDblClickRow: function(index, row) { editRoomTypeModalBY(row); }
		">
    <thead>
        <tr>
            <th data-options="field:'TypeName',sortable:true,resizable:false">
                <%: Html.Language("Type")%>
            </th>
            <th data-options="field:'Outlet',sortable:true,resizable:false">
                <%: Html.Language("Device")%>
            </th>
            <th data-options="field:'ModalAddress',sortable:true,resizable:false">
                <%: Html.Language("ReturnAddress")%>
            </th>
            <th data-options="field:'Circuit',sortable:true,resizable:false">
                <%: Html.Language("Circuit")%>
            </th>
            <%--<th data-options="field:'SceneNo',sortable:true,resizable:false">
                <%: Html.Language("SceneNo")%>
            </th>--%>
            <th data-options="field:'Name',sortable:true,resizable:false">
                <%: Html.Language("ChineseName")%>
            </th>
            <th data-options="field:'EnglishName',sortable:true,resizable:false">
                <%: Html.Language("EnglishName")%>
            </th>
            <th data-options="field:'TWName',sortable:true,resizable:false">
                <%: Html.Language("TWName")%>
            </th>
            <th data-options="field:'AliasName',sortable:true,resizable:false">
                <%: Html.Language("AliasName")%>
            </th>
            <th data-options="field:'ActiveIndicator',align:'center',resizable:false,formatter:deviceCheck">
                <%: Html.Language("Display")%>
            </th>
            <th data-options="field:'WXActiveIndicator',align:'center',resizable:false,formatter:deviceCheckWX">
                API
            </th>
            <th data-options="field:'Beep',align:'center',resizable:false,formatter:beepCheck">
                <%: Html.Language("SoundAlarm")%>
            </th>
            <th data-options="field:'Power',sortable:true,resizable:false">
                <%: Html.Language("PowerWatt")%>
            </th>
            <th data-options="field:'Sort',align:'center',sortable:true,resizable:false">
                <%: Html.Language("Sort")%>
            </th>
        </tr>
    </thead>
</table>
<div id="tbRelationDeviceBY">
    <a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-reload',plain:true"
        onclick="$('#dgRoomModalBY').datagrid('reload');">
        <%: Html.Language("Refresh")%></a> <a href="javascript:void(0)" class="easyui-linkbutton"
                data-options="iconCls:'icon-edit',plain:true" onclick="editRoomTypeModalBY()">
                <%: Html.Language("Edit")%></a> 
</div>
<script type="text/javascript">
    //回路是否显示
    function deviceCheck(val, row) {
        var url = '/RoomType/SaveDeviceDisplayChange/';
        if (val) {
            return '<input type="checkbox" checked="checked" onchange="updateDisplay(this,\'' + row.ID + '\',\'' + url + '\')" />';
        } else {
            return '<input type="checkbox" onchange="updateDisplay(this,\'' + row.ID + '\',\'' + url + '\')" />';
        }
    }
    //微信是否能控制
    function deviceCheckWX(val, row) {
        var url = '/RoomType/SaveRoomTypeWXDevice/';
        if (val) {
            return '<input type="checkbox" checked="checked" onchange="updateDisplay(this,\'' + row.ID + '\',\'' + url + '\')" />';
        } else {
            return '<input type="checkbox" onchange="updateDisplay(this,\'' + row.ID + '\',\'' + url + '\')" />';
        }
    }
    //是否报警
    function beepCheck(val, row) {
        var url = '/RoomType/SaveBeepDisplayChange/';
        var disabled = row.Type == 4 ? "" : "disabled";
        if (val) {
            return '<input type="checkbox" ' + disabled + ' checked="checked" onchange="updateDisplay(this,\'' + row.ID + '\',\'' + url + '\')" />';
        } else {
            return '<input type="checkbox" ' + disabled + ' onchange="updateDisplay(this,\'' + row.ID + '\',\'' + url + '\')" />';
        }
    }    
</script>
