Hi,
I try to implement deleting a row with Ajax, similar to this example: http://samples.infragistics.com/2010.3/WebFeatureBrowser/srcview.aspx?path=WebHierarchicalDataGrid/WebHierarchicalDataGrid_DeletingParentRow.src
When I click the Delete button I receive: "Async response failure: equest.readyState == 4". I use Version=10.3.20103.2013.
Sample code:
<ig:WebHierarchicalDataGrid ID="whdg" runat="server" Height="400px" Width="700px" HeightAutoGenerateBands="False" AutoGenerateColumns="False" Key="LLL" AutoGenerateBands="False" DataKeyFields="Pk" InitialDataBindDepth="-1" InitialExpandDepth="2" ViewStateMode="Disabled"> <Bands> </Bands> <Columns> <ig:TemplateDataField Key="Delete" VisibleIndex="0" Width="16"> <ItemTemplate> <asp:ImageButton ID="btnDelete" runat="server" CommandArgument='<%# Eval("Pk") %>' AlternateText="Delete" ImageUrl="~/delete.gif" CausesValidation="False" OnClientClick="DeleteRow(); return false;" /> </ItemTemplate> </ig:TemplateDataField> <ig:TemplateDataField Key="Name" VisibleIndex="1"> <ItemTemplate> <asp:Literal ID="Literal1" runat="server" Text='<%# DataBinder.Eval(((Infragistics.Web.UI.TemplateContainer)Container).DataItem, "Name") %>'></asp:Literal> </ItemTemplate> <Header Text="name" /> </ig:TemplateDataField> </Columns> <Behaviors> <ig:Selection CellClickAction="Row" RowSelectType="Single"> </ig:Selection> <ig:EditingCore> <Behaviors> <ig:RowDeleting /> </Behaviors> </ig:EditingCore> </Behaviors> </ig:WebHierarchicalDataGrid> <script type="text/javascript"> function DeleteRow() { var grid = $find('<%= whdg.ClientID %>'); var gridRows = grid.get_gridView().get_rows(); var selectedRows = grid.get_gridView().get_behaviors().get_selection().get_selectedRows(); for (var i = selectedRows.get_length() - 1; i >= 0; i--) { var row = selectedRows.getItem(i); gridRows.remove(row); } } </script>
public class TestObj { private string _pk; private string _name; public string Pk { get { return _pk; } set { _pk = value; } } public string Name { get { return _name; } set { _name = value; } } } public List<TestObj> L { get { return (List<TestObj>)Session["TestObj"]; } set { Session["TestObj"] = value; } } protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { L = new List<TestObj>() { new TestObj() { Name = "Name1", Pk = "1" }, new TestObj() { Name = "Name2", Pk = "2" }, new TestObj() { Name = "Name3", Pk = "3" }, new TestObj() { Name = "Name4", Pk = "4" } }; } BindGrid(); } private void BindGrid() { Infragistics.Web.UI.DataSourceControls.WebHierarchicalDataSource whds = new Infragistics.Web.UI.DataSourceControls.WebHierarchicalDataSource(); Infragistics.Web.UI.DataSourceControls.DataView view = new Infragistics.Web.UI.DataSourceControls.DataView(); view.DataSource = L; view.ID = "L"; whds.DataViews.Add(view); whdg.DataSource = whds; whdg.DataBind(); }
Hello,
There is probably an exception that occurred on the serve side. You can see the message if you look at the Net traffic in a firebug.
We'll fix the message box in the next Service Release, sorry for inconvenience.
10x, it works now :-)
Hello ppopov,
You are using List<> as a DataSource.
In this case you should handle RowDeleting event and manually delete the data.
ViewStateMode="Disabled" onrowsdeleting="whdg_RowsDeleting">
<ig:EditingCore AutoCRUD="false">
protected void whdg_RowsDeleting(object sender, Infragistics.Web.UI.GridControls.RowDeletingEventArgs e)
{
String key = ((Infragistics.Web.UI.GridControls.ControlDataRecord)(e.Row)).DataKey[0].ToString();
L.RemoveAll(p => p.Pk == key);
BindGrid();
}
Please let me know if you need further assistance regarding this.