This is a migrated thread and some comments may be shown as answers.

Client-side delete

4 Answers 131 Views
Grid
This is a migrated thread and some comments may be shown as answers.
B
Top achievements
Rank 1
B asked on 18 Aug 2008, 08:22 PM
I am using a grid and doing batch updates to my database. I want to delete the row from the grid on the client side only (does not effect my data source). I need an image button that will do this. It should only be visible when the grid is in edit mode (In-Place edit mode). Is this possible?

Thank you,
Blake

4 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 19 Aug 2008, 05:13 AM
Hello Blake,

To achieve the required scenario, you can use a GridClientDeleteColumn and set its ButtonType property as ImageButton(given below).
aspx:
<telerik:GridClientDeleteColumn ButtonType="ImageButton" ImageUrl="~/images/Delete.gif" UniqueName="Delete"
</telerik:GridClientDeleteColumn> 

To make this column visible only during EditMode you can try out the following code.
cs:
  protected void RadGrid2_ItemDataBound(object sender, GridItemEventArgs e) 
    { 
        if (e.Item is GridEditableItem && e.Item.IsInEditMode) 
        { 
            GridEditableItem edit = (GridEditableItem)e.Item; 
            ImageButton imgbtn = (ImageButton)edit["Delete"].Controls[0]; 
            imgbtn.Visible = true
        } 
        else if(e.Item is GridDataItem) 
        { 
            GridDataItem edit = (GridDataItem)e.Item; 
            ImageButton imgbtn = (ImageButton)edit["Delete"].Controls[0]; 
            imgbtn.Visible = false
        } 
    } 

Thanks
Princy.
0
B
Top achievements
Rank 1
answered on 19 Aug 2008, 12:36 PM
Thank you. That worked but now it broke another part of my code.

I am using a CommandItemTemplate Button to put the entire grid in edit mode using the code below. My problem is that when I put the grid in edit mode, then delete a row (using the code you provided above), and then click the cancel button (which should cancel all changes) I get a javascript error.

protected void commissionPoolRadGrid_ItemCommand(object source, GridCommandEventArgs e) 
        { 
            switch (e.CommandName) 
            { 
                case "Edit"
                    foreach (GridDataItem item in commissionPoolRadGrid.MasterTableView.Items) 
                    { 
                        item.Edit = true
                    } 
                    commissionPoolRadGrid.Rebind(); 
                    break
                case "CancelAll"
                    foreach (GridDataItem item in commissionPoolRadGrid.MasterTableView.Items) 
                    { 
                        item.Edit = false
                    } 
                    commissionPoolRadGrid.Rebind(); 
                    break
                default
                    break
            } 
        } 

Here is where the javascript error occurs. The error says "Object Required".
_removeDropDown:function(){ 
var _31=this.get_dropDownElement().parentNode; 
_31.parentNode.removeChild(_31); 
if(this._disposeChildElements){ 
Sys.WebForms.PageRequestManager.getInstance()._destroyTree(_31); 
if(!$telerik.isSafari){ 
_31.outerHTML=null
this._dropDownElement=null

Thanks,
Blake


0
B
Top achievements
Rank 1
answered on 20 Aug 2008, 12:17 PM
ttt
0
Nikita Gourme
Top achievements
Rank 1
answered on 22 Aug 2008, 01:34 PM
Since it would be hard for any forum user to pinpoint the cause of the error, consider isolating the case in a test project and submit it via the Telerik support system. A support officer will handle your case and will advice you how to proceed.

Nikita
Tags
Grid
Asked by
B
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
B
Top achievements
Rank 1
Nikita Gourme
Top achievements
Rank 1
Share this question
or