Undo Deletion of a Record

Hi,

I want to create an option to 'undo' a deletion from the grid. I saw in the documentation that I can easily delete record(s) using this.gridGroupingControl1.Table.Records.DeleteRecords(rec); But is there a way to 'undo' it?

Alternatively, is there a way to hide/unhide selected records from the grid grouping control?

Thanks,
Swetaketu

1 Reply

PM Piruthiviraj Malaimelraj Syncfusion Team November 22, 2016 05:46 AM UTC

Hi Swetaketu, 

Thanks for your interest in Syncfusion products. 

We have analyzed your scenario and created the simple sample as per your requirement. In order to hide/unhide the records of grid, AddRange/Remove methods of RowHiddenEntries can be used. Please make use of the below code, 
 
Code example: 
void chk_hide_CheckStateChanged(object sender, EventArgs e) 
{ 
    GridRowHidden[] hiddenrows; 
    if (chk_hide.Checked) 
    { 
        int n = this.gridGroupingControl1.Table.SelectedRecords.Count; 
        int rowIndex; 
        hiddenrows = new GridRowHidden[n]; 
        for (int i = 0; i < n; i++) 
        { 
            rowIndex = this.gridGroupingControl1.Table.SelectedRecords[i].Record.GetRowIndex(); 
            hiddenrows[i] = new GridRowHidden(rowIndex); 
        } 
        //Hide the selected rows. 
        this.gridGroupingControl1.TableControl.Model.RowHiddenEntries.AddRange(hiddenrows); 
    } 
    else 
    { 
        //Unhide the selected rows. 
        while (this.gridGroupingControl1.TableControl.Model.RowHiddenEntries.Count > 0) 
        { 
            this.gridGroupingControl1.TableControl.Model.RowHiddenEntries.Remove(this.gridGroupingControl1.TableControl.Model.RowHiddenEntries[0]); 
        } 
    } 
} 
 
Sample link: 

Please refer the below KB for further references, 

Regards, 
Piruthiviraj

Loader.
Up arrow icon