[Ext.Net] GridCommand 用法

前台
 
<script type="text/javascript">
    var prepare = function(grid, toolbar, rowIndex, record) {
        var EditButton = toolbar.items.get(0);
        var DetailButton = toolbar.items.get(1);
        var SendButton = toolbar.items.get(2);
        var CheckButton = toolbar.items.get(3);
        var RejectButton = toolbar.items.get(4);
        var InactiveButton = toolbar.items.get(5);
        var PDFButton = toolbar.items.get(6);
        
        if (record.data.STATUS == "S" || record.data.STATUS == null || record.data.STATUS == "") {
            CheckButton.setDisabled(true);
            RejectButton.setDisabled(true);
        }            
        if (record.data.CHECK_FLAG == "C") {
            EditButton.setDisabled(true);
            SendButton.setDisabled(true);
            CheckButton.setDisabled(true);
            RejectButton.setDisabled(true);
        }            
        if (record.data.INACTIVE_FLAG == "I") {
            EditButton.setDisabled(true);
            SendButton.setDisabled(true);
            CheckButton.setDisabled(true);
            RejectButton.setDisabled(true);
            InactiveButton.setDisabled(true);
            PDFButton.setDisabled(true);
        }
    };                 
</script>

<ColumnModel>
    <Columns>                                  
        <ext:CommandColumn Header="操作" Align="Center" Width="325">
            <Commands>
                <ext:GridCommand CommandName="Edit" Text="編輯" ToolTip-Text="編輯" Icon="TableEdit"
                    StandOut="true">
                </ext:GridCommand>
                <ext:GridCommand CommandName="Detail" Text="明細" ToolTip-Text="明細" Icon="TableMultiple"
                    StandOut="true">
                </ext:GridCommand>
                <ext:GridCommand CommandName="Send" Text="送簽" ToolTip-Text="送簽" Icon="PageGo" StandOut="true">
                </ext:GridCommand>
                <ext:GridCommand CommandName="Check" Text="簽核" ToolTip-Text="簽核" Icon="Tick" StandOut="true">
                </ext:GridCommand>
                <ext:GridCommand CommandName="Reject" Text="駁回" ToolTip-Text="駁回" Icon="BulletCross"
                    StandOut="true">
                </ext:GridCommand>
                <ext:GridCommand CommandName="Inactive" Text="失效" ToolTip-Text="失效" Icon="PageCancel"
                    StandOut="true">
                </ext:GridCommand>
                <ext:GridCommand CommandName="PDF" Text="PDF" ToolTip-Text="PDF" Icon="PageWhiteAcrobat"
                    StandOut="true">
                </ext:GridCommand>
            </Commands>
            <PrepareToolbar Fn="prepare" />
        </ext:CommandColumn>
	<Columns>
<ColumnModel>
<LoadMask ShowMask="true" />
<Listeners>
    <Command Handler="if(command=='Edit'){Ext.net.Mask.show({msg:'Loading...'}); } 
    else if(command=='Detail'){#{WindowDetail}.show();Ext.net.Mask.show({msg:'Loading...'});} 
    else if(command=='Send'){Ext.Msg.prompt('提示','確認送簽嗎?',function(id,msg){if(id=='ok'){Ext.net.DirectMethods.Send(rowIndex,command,record.data.HEADER_ID,msg);}})}  
    else if(command=='Check'){Ext.Msg.prompt('提示','確認核准嗎?',function(id,msg){if(id=='ok'){Ext.net.DirectMethods.Check(rowIndex,command,record.data.HEADER_ID,msg);}})}  
    else if(command=='Reject'){Ext.Msg.prompt('提示','請輸入駁回原因',function(id,msg){if(id=='ok'){Ext.net.DirectMethods.Reject(rowIndex,command,record.data.HEADER_ID,msg);}})}  
    else if(command=='Inactive'){Ext.Msg.prompt('提示','請輸入失效原因',function(id,msg){if(id=='ok'){Ext.net.DirectMethods.Inactive(rowIndex,command,record.data.HEADER_ID,msg);}})}  
    else if(command=='PDF'){Ext.net.Mask.show({msg:'Loading...'}); } 
    Ext.net.DirectMethods.gpGridPanelCommand(command,record.data.HEADER_ID,{success: function() {Ext.net.Mask.hide();}});">
    </Command>
</Listeners>


後台C# 
[DirectMethod]
public void gpGridPanelCommand(string command, string headerID)
{
    if (command == "Edit")
    {
        Edit(headerID);
    }
    else if (command == "Detail")
    {
        Detail(headerID);
    }
    else if (command == "PDF") 
    {
        PDF(headerID);
    }
}

public void Edit(string headerID)
{
    ...
}

public void Detail(string headerID)
{
    ...
}

public void PDF(string headerID)
{
    ...
}

[DirectMethod]
public void Send(int rowIndex, string command, string headerID, string msg)
{
    ...
}

[DirectMethod]
public void Reject(int rowIndex, string command, string headerID, string msg)
{
    ...
}

[DirectMethod]
public void Check(int rowIndex, string command, string headerID, string msg)
{
    ...
}

[DirectMethod]
public void Inactive(int rowIndex, string command, string headerID, string msg)
{
    ...
}
參考網址:
By Hao★

留言

熱門文章

[C#] 將DataTable轉換成Html格式表格

[MS SQL] 查詢所有Procedure