Feb 24, 2011, 9:16 AM
Deleting row in GridPanel
Hi,
I have a GridPanel which has a CommandColumn containing a delete button.
If I click the button nothing happens, however if I click on the 'Name' column it then removes from the grid.
Why won't it delete the row when I click the button?
Here is the testing code:
I have a GridPanel which has a CommandColumn containing a delete button.
If I click the button nothing happens, however if I click on the 'Name' column it then removes from the grid.
Why won't it delete the row when I click the button?
Here is the testing code:
<%@ Page Language="C#" %>
<%@ Import Namespace="System.Data" %>
<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
var store = this.GridPanel1.GetStore();
store.DataSource = dtTest();
store.DataBind();
}
}
protected void odsInvigilator_Selecting(object sender, ObjectDataSourceMethodEventArgs e)
{
e.InputParameters["exam_id"] = Values.exam_id;
}
public DataTable dtTest()
{
DataTable dt = new DataTable();
dt.TableName = "Test";
dt.Columns.Add("name_id", typeof(int));
dt.Columns.Add("name", typeof(string));
for (int i = 1; i <= 5; i++)
{
dt.Rows.Add(i, "Name" + i.ToString());
}
return dt;
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>Test</title>
</head>
<body>
<form id="form1" runat="server">
<ext:ResourceManager ID="ResourceManager1" runat="server">
</ext:ResourceManager>
<div>
<ext:GridPanel ID="GridPanel1" runat="server" Height="200" Width="550" Title="Test Names">
<Store>
<ext:Store ID="Store1" runat="server">
<Reader>
<ext:JsonReader IDProperty="name_id">
<Fields>
<ext:RecordField Name="name" />
</Fields>
</ext:JsonReader>
</Reader>
</ext:Store>
</Store>
<ColumnModel ID="ctl279">
<Columns>
<ext:Column ColumnID="colInv" Header="Name" DataIndex="name" Width="400" />
<ext:CommandColumn Width="30">
<Commands>
<ext:GridCommand Icon="Delete" CommandName="Delete">
<ToolTip Text="Delete" />
</ext:GridCommand>
</Commands>
</ext:CommandColumn>
</Columns>
</ColumnModel>
<SelectionModel>
<ext:RowSelectionModel runat="server" SingleSelect="true" />
</SelectionModel>
<Listeners>
<Click Handler="#{GridPanel1}.deleteSelected();" />
</Listeners>
</ext:GridPanel>
</div>
</form>
</body>
</html>