<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<dynamic>" %>

<table id="dgWXMenu" class="easyui-datagrid" style="width: 100%; height: auto;" data-options="
            toolbar: '#tbWXMenu',
			border: false,
			singleSelect: true,
			rownumbers: true,
			striped: true,
			fit: true,
			fitColumns: true,
			idField: 'ID',
			method: 'POST',
            url: '/RoomType/LoadRoomTypeWXMenus/',
			queryParams: { roomTypeID:<%: Convert.ToInt16(Request.QueryString.Get("roomTypeID")) %>}
		">
    <thead>
        <tr>
            <th data-options="field:'Name',width:100,resizable:false">
                <%: Html.Language("ChineseName")%>
            </th>
            <th data-options="field:'EName',width:100,resizable:false">
                <%: Html.Language("EName")%>
            </th>
            <th data-options="field:'TWName',width:100,resizable:false">
                <%: Html.Language("TWName")%>
            </th>
            <th data-options="field:'Sort',sortable:true,align:'center',resizable:false">
                <%: Html.Language("Sort")%>
            </th>
            <th data-options="field: 'ActiveIndicator',align: 'center',resizable:false,formatter: activeIndicatorFormatter">
                <%: Html.Language("Display")%>
            </th>
            <th data-options="field: 'TakePower',align: 'center',resizable:false,formatter: takePowerFormatter">
                <%: Html.Language("TakePower")%>
            </th>
        </tr>
    </thead>
</table>
<div id="tbWXMenu">
    <a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-reload',plain:true"
        onclick="$('#dgWXMenu').datagrid('load',{roomTypeID:<%: Convert.ToInt16(Request.QueryString.Get("roomTypeID")) %>})"><%: Html.Language("Refresh")%></a>
</div>
<script type="text/javascript">
    function activeIndicatorFormatter(val, row) {
        if (val) {
            return '<input type="checkbox" checked="checked" onchange="activeIndicatorChange(this,\'' + row.ID + '\')" />';
        } else {
            return '<input type="checkbox" onchange="activeIndicatorChange(this,\'' + row.ID + '\')" />';
        }
    }
    function activeIndicatorChange(sender, id) {
        var params = { id: id, activeIndicator: $(sender).is(":checked") };
        $.tools.post(params, '/RoomType/SaveRoomTypeWXMenus/');
    }
    function takePowerFormatter(val, row) {
        if (val) {
            return '<input type="checkbox" checked="checked" onchange="takePowerChange(this,\'' + row.ID + '\')" />';
        } else {
            return '<input type="checkbox" onchange="takePowerChange(this,\'' + row.ID + '\')" />';
        }
    }
    function takePowerChange(sender, id) {
        var params = { id: id, takePower: $(sender).is(":checked") };
        $.tools.post(params, '/RoomType/SaveRoomTypeWXMenusTakePower/');
    }
</script>
