前台代码:
<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")
{
。。。。。。。。
}
二:
前台
<DirectEvents>
<Command OnEvent="Command">
<ExtraParams>
<extnet:Parameter Name="Id" Value="record.data.Id" Mode="Value" />
<extnet:Parameter Name="command" Value="command" Mode="Raw" />
</ExtraParams>
<Confirmation BeforeConfirm="if (command=='attach') return false;" ConfirmRequest="true" Message="Are you sure you want to delete" Title="Delete" />
</Command>
</DirectEvents>
后台
protected void Command(object sender, DirectEventArgs e)
{
var command = e.ExtraParams["command"].ToString();
var Id = ConvertHelper.ToInt(e.ExtraParams["Id"].ToString());
X.Msg.Alert("Command", e.ExtraParams["id"] + " : " + e.ExtraParams["command"]).Show();
}