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

how to hide EditForm templatae after updating or inserting is accomplished

9 Answers 363 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jaime
Top achievements
Rank 1
Jaime asked on 13 Oct 2008, 02:00 PM
Hello... I am using a custom template for editing or inserting elements in a grid. I implemented the UpdateCommand where I call a stored procedure in order to add or update information.

Before that event returns, I am calling Rebind method of the grid which causes the edited item be refreshed, but the edit form remains visible. How can I hide the edit form?

Any help will be greatly appreciated.

Thanks
Jaime

9 Answers, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 2
answered on 14 Oct 2008, 04:04 AM
Hello Jaime,

Have you set the AllowAutomaticUpdates to true? If yes, try setting it to false and then see if the editform disappears. If not, you can add the following line of code to hide the edit form after performing update.
cs:
protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e) 
    { 
        if (e.CommandName == RadGrid.UpdateCommandName) 
        { 
            // code to update 
            RadGrid1.MasterTableView.ClearEditItems(); 
        } 
    } 

Thanks
Princy.
0
Jaime
Top achievements
Rank 1
answered on 14 Oct 2008, 01:08 PM
Hello Princy... thanks for your reply.

What you suggested worked only when updating an item. When the insert form is visible, using the ClearEditItems method doesn't have effect.

This is the whole implementation of UpdateCommand I have (which is called when inserting:and updating)

    protected void grdTipoEvento_UpdateCommand(object source, GridCommandEventArgs e)  
    {  
        if (e.Item is GridEditFormInsertItem)  
            FrameWork.Logging.TipoEvento.AgregarTipoEvento((e.Item.FindControl("txtNombre") as TextBox).Text);  
        else  
            FrameWork.Logging.TipoEvento.ActualizarTipoEvento(Convert.ToInt32(grdTipoEvento.MasterTableView.DataKeyValues[e.Item.ItemIndex]["Codigo"]), (e.Item.FindControl("txtNombre") as TextBox).Text, true);  
          
        grdTipoEvento.MasterTableView.ClearEditItems();  
        grdTipoEvento.Rebind();  
    }  

Any further help would be greatly appreciated,

Jaime
0
Accepted
Princy
Top achievements
Rank 2
answered on 15 Oct 2008, 03:36 AM
Hello Jaime,

To close the insert form after inserting an item, you can replace the above given line of code with the following code after performing the insert operation.
cs:
RadGrid1.MasterTableView.IsItemInserted = false;  

Thanks
Princy.
0
Steve Todd
Top achievements
Rank 1
answered on 10 Mar 2009, 05:22 PM
I can't get my Insert form to disappear. I've followed the examples on the site but I have obviously missed something.

I have AllowAutomaticInserts="false" and AllowAutomaticUpdates="false" and this as the item command from this thread but the insert form remains and I get the error "Insert Item Is Available Only When The Grid Is In Insert Mode"

 

Protected Sub rgrdEntry_ItemCommand(ByVal source As Object, ByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles rgrdEntry.ItemCommand

 

 

Try

 

 

If (TypeOf e.Item Is GridEditFormInsertItem) Then

 

 

If e.CommandName = "PerformInsert" Then

 

rgrdEntry.MasterTableView.IsItemInserted =

False

 

 

End If

 

 

End If

 

 

       Catch ex As Exception

 

 

    End Try

 

 

End Sub

 



Can you give me working example in VB instead of C#?

Cheers

Steve
0
Princy
Top achievements
Rank 2
answered on 11 Mar 2009, 09:42 AM
Hello Steve,

Try modifying your code as follows and see if it helps:
cs:
Protected Sub rgrdEntry_ItemCommand(ByVal source As ObjectByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles rgrdEntry.ItemCommand 
 Try 
  If e.CommandName = "PerformInsert" Then 
   If (TypeOf e.Item Is GridEditFormInsertItem) Then 
     rgrdEntry.MasterTableView.IsItemInserted =False 
   End If 
  End If 
    Catch ex As Exception 
 End Try 
End Sub  

Thanks
Princy.
0
Steve Todd
Top achievements
Rank 1
answered on 11 Mar 2009, 09:57 AM
Hi

Thanks for the quick reply, but no joy with the code you suggested. I get a web page error

Insert item is available only when grid is in insert mode.

I've noticed the MasterTableView.IsItemInserted = False within the ItemCommand method gets executed before the InsertCommand method. Would this be the cause of the above error?

Steve



0
Nicolaï
Top achievements
Rank 2
answered on 25 Mar 2009, 09:11 AM
Having the same issue...
My config: the grid is not allowing edits/inserts/deletes by default, and based on " is admin checks" I change the attributes to true.
0
Sebastian
Telerik team
answered on 25 Mar 2009, 09:22 AM
Hi Nicolai,

If the directions provided so far in this thread are not helpful, I suggest you prepare a small working version of your project, illustrating the issue, and send it enclosed to a regular support ticket. We will examine your entire code implementation in detail and will get back to you with our findings.

Kind regards,
Sebastian
the Telerik team

Check out Telerik Trainer , the state of the art learning tool for Telerik products.
0
Nicolaï
Top achievements
Rank 2
answered on 25 Mar 2009, 09:29 AM
Hello,

I just understood why now.. (thx to http://www.telerik.com/community/forums/aspnet/grid/after-insert-the-edit-form-visible.aspx)
The reason it wasn't working is the grid needs to be AllowAutomaticInserts=false in order to use the code: .IsItemInserted = False.

So as a workaround, I do:

Protected Sub commentsDG_InsertCommand(ByVal source As Object, ByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles commentsDG.InsertCommand
            commentsDG.AllowAutomaticInserts = False
            commentsDG.MasterTableView.AllowAutomaticInserts = False
[...code...]
            commentsDG.MasterTableView.IsItemInserted = False
End Sub

(And the admin check puts it back to AllowAutomaticInserts, on page load)

All works now...

(ps: sending code is hard when you're working with sensitive data. I'm just a programmer and I do not want to take any chances when it comes to the clients rules.. It usually requires more work to make a neutral sample than finding another way :/)
Tags
Grid
Asked by
Jaime
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Jaime
Top achievements
Rank 1
Steve Todd
Top achievements
Rank 1
Nicolaï
Top achievements
Rank 2
Sebastian
Telerik team
Share this question
or