<%@ page language="C#" autoeventwireup="true" inherits="ColumnManage_ColumnEdit, App_Web_vkwqxb1y" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
    <title>编辑栏目结构</title>
    <link rel="stylesheet" href="../style/Common.css" />
    <link rel="stylesheet" href="../style/Frame.css" />

    <script type="text/javascript" src="../Script/Common.js"></script>
    <script type="text/javascript">
var siteName, colName, fieldName;
var Ajax;

function Page_Load()
    {
	siteName =  Common.GetQueryString('sitename');
	colName = Common.GetQueryString('colname');
	if( !siteName || !colName ) return;
	
	Ajax = new AjaxRequest( 'FieldOp.aspx', FreshSelf, Operate_Err );
	
	lkContentList.href='ContentList.aspx' + location.search;
	
	var ColumnFields = $('ColumnFields');
	var trs = ColumnFields.firstChild.childNodes
	if( !trs ) return;
	for( var i=1; i<trs.length; i++ ){
	    if( trs[i].childNodes[4].innerText == 'sys' ){
	        var rd = trs[i].childNodes[0].firstChild;
	        if( !rd ) continue;
	        rd.disabled = true;
	        rd.onclick = null;
	        rd.checked = false;
	    }
	}
    }
function Operate_Err( msg )
    {
	alert( msg );
    }

function SelectField( sel )
    {
	if( sel && sel.checked && sel.value ){
//	    $('btnEditField').disabled = false;
	    $('btnHideField').disabled = false;
	    $('btnDelField').disabled = false;
	    fieldName = sel.value;
	    
	    var hidden;
	    try{
	        hidden = sel.parentNode.parentNode.childNodes[3].innerText
	    } catch( e ){ ; }
	    if( hidden == '显示' ){
	        $('btnHideField').value = '隐藏字段';
	    } else if( hidden == '隐藏' ){
	        $('btnHideField').value = '显示字段';
	    }
	};
    }

function Operate( opType )
    {
	if( !siteName || !colName ) return;
	
	var post = new UrlText( ['opType', opType], ['sitename', siteName], ['colname', colName], ['fieldname', fieldName] );
	var url = new UrlText( 'FieldEdit.aspx', post.Text, 'uni' );
	
	switch( opType ){
	case'AddField': 	// 添加字段 // Dialog -- Fresh
	case'EditField':	// 编辑字段 // Dialog -- Fresh
	    var ret = Common.ShowDialog( 1, url.Text, {width:280, height:220} );
	    if(ret && ret.reload )
	        FreshSelf();
	    break;

	case'DelField': 	// 删除字段 // Confirm -- Ajax
	    if( confirm('您确定要删除吗?') ){
	        Ajax.Post( post.Text );
	    }
	    break;

	case'HideField':	// 显示/隐藏字段 // Ajax
	case'TextIndex':	// 设置为文本索引 // Ajax
	    Ajax.Post( post.Text );
	    break;
	}
    }
function FreshSelf()
    {
	self.location.reload( true );
    }
    </script>
</head>
<body onload="Page_Load();"><form id="form1" runat="server">

    <div class="TopArea">
        <div class="LeftBlock">
            <span class="Heading">编辑栏目结构</span>
            <asp:Label ID="lbColumnPath" runat="server" Text="[]" CssClass="Notes"/>
        </div>
        <div class="RightBlock">
            <a id="lkContentList" href="#">编辑该栏目内容</a>
        </div>
    </div>

    <div class="ContentArea">
        <asp:GridView ID="ColumnFields" runat="server" AllowPaging="false" AllowSorting="false" DataKeyNames="name" 
                       CellPadding="1"  CellSpacing="1" GridLines="None" AutoGenerateColumns="False" 
                       CssClass="DataTable" OnPageIndexChanging="ColumnFields_PageIndexChanging" Width="650">
	    <PagerSettings FirstPageText="&lt;&lt;" LastPageText="&gt;&gt;" Mode="NumericFirstLast"
	                   NextPageText="&gt;" PreviousPageText="&lt;" />
            <Columns>
                <asp:TemplateField HeaderText="选">
                    <ItemTemplate>
                        <input id="rdName" type="radio" name="rdName" value="<%# Eval("name")%>" onclick="SelectField(this);" />
                    </ItemTemplate>
                    <ItemStyle CssClass="checkCol" />
                </asp:TemplateField>
                <asp:BoundField DataField="Title"  HeaderText="全名" />
                <asp:BoundField DataField="type" HeaderText="字段类型" />
                <asp:BoundField DataField="hidden" HeaderText="隐藏" />
                <asp:BoundField DataField="visible" HeaderText="显示在" />
                <asp:BoundField DataField="notNull" HeaderText="允许为空" />
                 <%--<asp:BoundField DataField="NameIndex" HeaderText="文本索引" />--%>
           </Columns>
            <AlternatingRowStyle CssClass="Alternating" />
        </asp:GridView>
        
        <div>
            <input id="btnAddField" type="button" class="Button" value="添加字段" onclick="Operate('AddField');" disabled="disabled" runat="server"/>
	    <%--<input id="btnEditField" type="button" class="Button" value="编辑字段" onclick="Operate('EditField');" disabled="disabled" style="display:onne;"/>--%>
	    <input id="btnHideField" type="button" class="Button" value="隐藏字段" onclick="Operate('HideField');" disabled="disabled"/>
	    <input id="btnDelField" type="button" class="Button" value="删除字段" onclick="Operate('DelField');" disabled="disabled"/>
	    <%--<input id="btnTextIndex" type="button" class="Button" value="文本索引" onclick="Operate('TextIndex');" disabled="disabled"/>--%>
        </div>
        <asp:Label ID="lbInfo" runat="server" ForeColor="Red"/>
    </div>

</form></body>
</html>

<%--
// nameRadios,
//	var postText = 'opType='+ opType.toLowerCase() +'&sitename='+ siteName +'&colname='+ colName +'&fieldname='+ fieldName;
//	var url = 'FieldEdit.aspx?'+ postText +'&uni='+ Common.UniqueValue();
//	    $('btnTextIndex').disabled = false;
<asp:BoundField DataField="name" HeaderText="字段名" />--%>
<%--SortExpression="ColumnName"--%>
<%--SortExpression="Title"--%>
<%--SortExpression="RecordTime"--%>
<%--SortExpression="Recorder"--%>