Y&歪

朝梦想前进!
Coolite 学习之四: GridPanel之Command事件

Coolite的GridPanel虽然不能想.net中的Gridview那样可视化操作,一下方法同样也能实现和GridView一样的Command事件

前台代码:

<form id="form1" runat="server">
    <div>
        <ext:ScriptManager ID="ScriptManager1" runat="server">
        </ext:ScriptManager>
        <ext:Store ID="Store1" runat="server" Height="300px" OnRefreshData="Store1_RefreshData">
            <Reader>
                <ext:JsonReader>
                    <Fields>
                        <ext:RecordField Name="NO">
                        </ext:RecordField>
                        <ext:RecordField Name="stdname" />
                        <ext:RecordField Name="stdsubject" />
                        <ext:RecordField Name="result" />
                    </Fields>
                </ext:JsonReader>
            </Reader>
        </ext:Store>
        <ext:GridPanel ID="GridPanel1" runat="server" StoreID="Store1" StripeRows="true"
            Height="300px" Title="学生成绩表" TrackMouseOver="true">
            <ColumnModel ID="ColumnModel1" runat="server">
                <Columns>
                    <ext:Column ColumnID="NO" Header="学号" Sortable="true" DataIndex="NO" Hidden="true">
                    </ext:Column>
                    <ext:Column ColumnID="Stdname" Header="姓名" Sortable="true" DataIndex="stdname" />
                    <ext:Column ColumnID="Stdsubject" Header="姓名" Sortable="true" DataIndex="stdsubject" />
                    <ext:Column ColumnID="Result" Header="成绩" Sortable="true" DataIndex="result" />
                    <ext:CommandColumn>
                        <Commands>
                            <ext:GridCommand Icon="NoteEdit" CommandName="Edit" Text="Edit">
                                <ToolTip Text="Edit" />
                            </ext:GridCommand>
                            <ext:GridCommand Icon="Delete" CommandName="Delete" Text="Delete">
                                <ToolTip Text="Delete" />
                              
                            </ext:GridCommand>
                        </Commands>
                    </ext:CommandColumn>
                </Columns>
            </ColumnModel>
            <Listeners>
                <Command Handler="Coolite.AjaxMethods.GridPanel1_Command(command,record.data.NO);" />
            </Listeners>
            <LoadMask ShowMask="true" />
            <BottomBar>
                <ext:PagingToolbar runat="server" PageSize="10" StoreID="Store1">
                </ext:PagingToolbar>
            </BottomBar>
            <SelectionModel>
                <ext:CheckboxSelectionModel ID="CheckboxSelectionModel1" runat="server">
                    <CustomConfig>
                        <ext:ConfigItem Name="checkOnly" Value="true" Mode="Raw" />
                    </CustomConfig>
                </ext:CheckboxSelectionModel>
            </SelectionModel>
        </ext:GridPanel>

 后台:

 


        [AjaxMethod]
        public void GridPanel1_Command(string command, string id)
        {
            if (command == "Edit")
            {

             。。。。。。。。。。

                  }

  else if (command == "Delete")
            {

       。。。。。。。。

}

posted on 2010-06-09 13:05  xinyu1020  阅读(2995)  评论(1编辑  收藏  举报