Hello,
I have a problem with WebDataGrid with deleting row. I have a page with several WebDataGrid, all with AutoCRUD = false, BatchUpdating = true and RowDeleting enabled (with del button and undo button).
The user can modify the data on the page and at the end sends all to the server to process it. Maybe is an stupid question, but in the postback, how can I detect deleted rows in the WebDataGrids? If I loop throw the WebDataDrid rows I see all the rows, including the deleted.
This is one of the WebDataGrid:
<ig:WebDataGrid ID="wdgOperaciones" EnableDataViewState ="true" runat="server" ClientIDMode ="Static" AutoGenerateColumns =" false" BackColor ="white" BorderColor ="#336666" BorderStyle="Double" BorderWidth="3px" CellPadding="4" Font-Size="Small" GridLines="Horizontal" Height="275px" Width="700px" HeaderCaptionCssClass ="CustomHeader"> <Columns> <ig:BoundDataField DataFieldName ="OPERACION" Key ="OPERACION" Header-CssClass ="Operacion"> <Header Text ="Operación"></Header> </ig:BoundDataField> </Columns>
<EditorProviders> <ig:DropDownProvider ID ="ComboOperaciones"> <EditorControl DropDownContainerMaxHeight="200px" EnableAnimations="False" EnableDropDownAsChild="False" ClientIDMode="Predictable"></EditorControl> </ig:DropDownProvider> </EditorProviders>
<Behaviors> <ig:RowSelectors RowNumbering="true" HeaderRowSelectorCssClass ="CustomRowSelectorHeader" />
<ig:EditingCore BatchUpdating ="true" AutoCRUD="False" >
<EditingClientEvents RowAdding ="wdgOperaciones_RowAdding" CellValueChanging ="wdgOperaciones_CellValueChanging" /> <Behaviors> <ig:RowDeleting Enabled ="true" ShowDeleteButton ="true" EnableInheritance =" true" ></ig:RowDeleting> <ig:RowAdding AddNewRowCssClass ="CustomNewRow"> <EditModeActions MouseClick="Single" /> <ColumnSettings> <ig:RowAddingColumnSetting ColumnKey ="OPERACION" EditorID ="ComboOperaciones" /> </ColumnSettings> </ig:RowAdding>
<ig:CellEditing> <EditModeActions MouseClick="Single" /> <ColumnSettings> <ig:EditingColumnSetting ColumnKey ="OPERACION" EditorID ="ComboOperaciones" /> </ColumnSettings> </ig:CellEditing>
</Behaviors> </ig:EditingCore> </Behaviors>
</ig:WebDataGrid>
Thanks for your help
Hello ACSA,
You can achieve this behavior by handling the RowDeleted event in the server. Here you can utilize the RowID provided by the RowDeletedEventHandler to identify the specific row that was marked for deletion in the client. A common example would be: Use rowID to delete row from your data source such that when your grid rebinds to your data source on PreRender that row will no longer appear on the client.
Here's a link to our API with more info on the RowDeleted event: http://help.infragistics.com/doc/ASPNET?page=Infragistics4.Web.v15.2~Infragistics.Web.UI.GridControls.WebDataGrid~RowDeleted_EV.html
Hello Sam,
I’ll try to investigate that you've commented, but I have some doubts. As I say, I have the batchUpdating to true because I want the option to undo a deleted row for example, so, I don’t want that the deleted rows disappear on the client (see image attached) With batchUpdating the changes (updated rows, new rows and deleted rows) are not send to the server until the postback and that’s true, in postback I get the updated rows and the new rows, but deleted rows too?
You say I have to delete the row from my data source and rebind the grid, but that is the opposite to batchUpdating ?
Thanks for your help.
Regards.
Hi Sam,
Thanks for all the info. I’ve continued testing and I discovered I don’t set DataKeyFields in any grid. Setting the correct DataKeyFields I get on postback the correct data from the grids.
With this and the rest of the information you have provided me, I have to test all the application again but it’s seem that all works.
Hi ACSA,
You will have to manually implement the CRUD functionality when you have the AutoCRUD flag set to false. You can implement this logic in the RowAdding, RowsDeleting and RowUpdating events. These events will be handled by the server and, therefore, only occur on PostBack (you can trigger PostBack by having a simple asp button on your page). From these events, you will be able to gather which row was modified, added and deleted on PostBack and makes the corresponding changes to your DataSource. Here's a link to our API on these events:
http://help.infragistics.com/Help/Doc/ASPNET/2015.2/CLR4.0/html/Infragistics4.Web.v15.2~Infragistics.Web.UI.GridControls.WebDataGrid~RowAdding_EV.html
http://help.infragistics.com/Help/Doc/ASPNET/2015.2/CLR4.0/html/Infragistics4.Web.v15.2~Infragistics.Web.UI.GridControls.WebDataGrid~RowsDeleting_EV.html
http://help.infragistics.com/Help/Doc/ASPNET/2015.2/CLR4.0/html/Infragistics4.Web.v15.2~Infragistics.Web.UI.GridControls.WebDataGrid~RowUpdating_EV.html
Note that the grid automatically binds to it's DataSource on PreRender so you don't have to call BindData after initial load of the page.
Here's a link to our cheat sheet that mentions how to implement CRUD logic, check out the section labeled "Implement CRUD logic": http://dl.infragistics.com/pg/cheat-sheet/InfragisticsNAforASPNETGridCheatSheet.pdf
Also, you can take a look at our sample on Batch Updating here: http://es.infragistics.com/samples/aspnet/data-grid/batch-updating
I’ve created a simple project to test.
The page contain a grid with EnableDataViewState ="true", BatchUpdating ="true" AutoCRUD="False", a textbox and a button. I populate the grid with a data table and when a click the button I loop throw the grid rows and paste de values into the textbox.
If I modify some row and click the button I can see the modify row. If I add a row the same, but for example, if I modify some row and later add a row, I can see the added row but all the modified rows changes the value to the initial value.
The same when I delete a row, the deleted row isn’t delete and modified rows change to its initials values.
At the end, I want to get in postback the added and updated rows to update the database. Can you help me?
Thanks.