[Ext.Net] GridPanel 多選並回傳後台

後台C# 
protected void btnCancel_Click(object sender, DirectEventArgs e)
{
    X.Msg.Confirm("提示", "删除將無法恢復是否確認刪除?", new MessageBoxButtonsConfig
    {
        Yes = new MessageBoxButtonConfig
        {
            Handler = "Ext.net.DirectMethods.Yes()",
            Text = "確認"     
        },
        No = new MessageBoxButtonConfig
        {
            Handler = "Ext.net.DirectMethods.No()",
            Text = "取消"
        }
    }).Show();
}

[DirectMethod]
public void Yes()
{
    RowSelectionModel sm = this.gpGridPanelID.SelectionModel.Primary as RowSelectionModel;
    if(sm.SelectedRows.Count != 0)
    {
    	string tempRowData = "";
    	foreach(SelectedRow row in sm.SelectedRows)
        {
            tempRowData = tempRowData + "," + row.RecordID ;
        }
    }
}
前台 

<ext:Store ID="StoreID" runat="server">
    <Reader>
        <ext:JsonReader IDProperty="HEADER_ID">
            <Fields>
                <ext:RecordField Name="HEADER_ID">
                </ext:RecordField>
                <ext:RecordField Name="USER_ID">
                </ext:RecordField>
                <ext:RecordField Name="CREATE_DATE">
                </ext:RecordField>
            </Fields>
        </ext:JsonReader>
    </Reader>
</ext:Store>

<ext:Panel ID="PanelID" runat="server" Layout="Fit" Border="false" Header="false">
    <Items>
        <ext:GridPanel ID="gpGridPanelID" runat="server" AutoScroll="true" StripeRows="true" TrackMouseOver="true" ColumnLines="true" Layout="Fit" StoreID="StoreID" AutoDoLayout="true">
            <SelectionModel>
                <ext:RowSelectionModel ID="RowSelectionMode" runat="server">
                </ext:RowSelectionModel>
            </SelectionModel>
            <ColumnModel>
                <Columns>
                    <ext:Column Header="HeaderID" DataIndex="HEADER_ID" Align="Center" Hidden="true">
                    </ext:Column>
                    <ext:Column Header="使用者" DataIndex="USER_ID" Align="Center" >
                    </ext:Column>
                    <ext:Column Header="日期" DataIndex="CREATE_DATE" Align="Center" >
                        <Renderer Fn="Ext.util.Format.dateRenderer('Y/m/d')" />
                    </ext:Column>
                </Columns>
            <ColumnModel>
        </ext:GridPanel>
    </Items>
</ext:Panel>

Ext.util.Format.dateRenderer('Y/m/d') 日期格式轉換 
AutoScroll="true" 顯示滾輪 
StripeRows="true" 斑馬紋 
TrackMouseOver="true" 滑鼠軌跡效果 

參考網址: 
By Hao★

留言

熱門文章

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

[MS SQL] 查詢所有Procedure