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

[Solved] CaptionFormatString="Edit Item : {0}"

4 Answers 238 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Shane P
Top achievements
Rank 1
Shane P asked on 29 Sep 2008, 09:40 AM
Hi everyone,
I am hoping for some help on something I am sure isn't a major.

I am taking advantage of the CaptionFormatString on a edit/insert form I am using. It works as it should when editing and when adding a form no text is displayed. When I insert a record (I keep the form open) the Caption is then displayed as Edit Item : {0}

Can I change this to be blank or a more friendly type of message?

Thank you

Shane

4 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 29 Sep 2008, 11:20 AM
Hi Shane ,

I guess you are trying to remove the CaptionFormatString when the Grid is in Insert mode. If so try the following code snippet.

CS:
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e) 
    { 
        if (e.Item.OwnerTableView.IsItemInserted) 
        { 
            RadGrid1.MasterTableView.EditFormSettings.CaptionFormatString = string.Empty; 
        } 
        else 
            RadGrid1.MasterTableView.EditFormSettings.CaptionFormatString = "CustomText"
    } 


Thanks
Princy.
0
Steve Newbery
Top achievements
Rank 1
answered on 07 Dec 2008, 12:13 PM
Princy, setting the PopUp caption in the ItemDataBound event does not work. I want to set the PopUp caption to "New Record" when it is opened for inserting, but it stays blank.

I guess the event is too late, so I tried using the ItemCommand event and that does work ok, but only when I have not set the CaptionFormatString declaratively:

    Protected Sub RadGrid1_ItemCommand(ByVal source As Object, ByVal e As GridCommandEventArgs)  
        If e.CommandName = "InitInsert" Then  
            RadGrid1.MasterTableView.EditFormSettings.CaptionFormatString = "New Record" 
        End If  
        If e.CommandName = "Edit" Then  
            RadGrid1.MasterTableView.EditFormSettings.CaptionFormatString = "Edit Record" 
        End If  
    End Sub  
 

I really wish there was a separate caption for Insert and Edit, for example InsertCaptionFormatString, and EditCaptionFormatString

Regards, Steve


0
Yavor
Telerik team
answered on 08 Dec 2008, 07:14 AM
Hi Steve,

Attached to this message, is a small application, which handles the functionality in question.
I hope it gets you started properly.

Sincerely yours,
Yavor
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Ron
Top achievements
Rank 1
answered on 11 Sep 2009, 12:10 PM
Princy,

You code snippet only works when you allow only one record to be modified at a time. If you allow editing and inserting at the same time (2 edit dialogs open) you overwrite the caption with the text of the last opened.

P.S. Steves solution does also overwrite the caption of the first opened.
In my opinion you should be able to point directly to the opened Dialog and set the caption. Please tell me if this is possible!

Thanks,
Ron
Tags
Grid
Asked by
Shane P
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Steve Newbery
Top achievements
Rank 1
Yavor
Telerik team
Ron
Top achievements
Rank 1
Share this question
or