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

Programmatically Change ConfirmText & ConfirmTitle in GridButtonColumn

6 Answers 613 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Mansour
Top achievements
Rank 1
Mansour asked on 24 Jan 2016, 12:47 PM

I tried to change the ConfirmText and ConfirmTitle for a GridButtonColumn from the back-end in the ItemDataBound event, but this only applies after a PostBack. So if on the first load of the page, I clicked the Delete button, it would delete without a confirmation window. However, after any PostBack, the confirmation window comes up successfully. Am I using the wrong event to change this?

 

 

01.protected void rgPackagesHistory_ItemDataBound(object sender, GridItemEventArgs e)
02.        {
03.            if (e.Item is GridDataItem)
04.            {
05.                ((GridButtonColumn)rgPackagesHistory.MasterTableView.GetColumnSafe("column1abc")).ConfirmTitle = rxM.GetString("DeleteConfirmationTitle", cul);
06.                ((GridButtonColumn)rgPackagesHistory.MasterTableView.GetColumnSafe("column1abc")).ConfirmText = rxM.GetString("DeleteConfirmation", cul);
07.            }
08.        }

 

6 Answers, 1 is accepted

Sort by
0
Mansour
Top achievements
Rank 1
answered on 25 Jan 2016, 12:24 PM
I hate to do this, but this post has almost been buried to the second page without any responses.. So, bump!
0
Mansour
Top achievements
Rank 1
answered on 26 Jan 2016, 06:08 AM
Bump!
0
Mansour
Top achievements
Rank 1
answered on 27 Jan 2016, 01:23 PM
Bump.......
0
Eyup
Telerik team
answered on 28 Jan 2016, 06:45 AM
Hello Ali,

You can try accessing the column on an earlier stage of the page life cycle, for example in the DataBinding event handler of the grid. Also, you can check the attached web site sample.

Regards,
Eyup
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
David
Top achievements
Rank 1
answered on 30 Aug 2020, 01:16 AM

I have been following this.

Your example is not very helpful. The goal is to dynamically update the RadConfrim message.

Can you please assist with a more relevant example?

0
Peter Milchev
Telerik team
answered on 02 Sep 2020, 09:19 AM

Hello David,

You can modify the code suggested by Eyup to call a JavaScript function where you can assign whatever message you want:

protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
{
    if (e.Item is GridDataItem)
    {
        GridDataItem item = e.Item as GridDataItem;
        ImageButton button = item["DeleteColumn"].Controls[0] as ImageButton;

        string dataKeyID = item.GetDataKeyValue("OrderID").ToString();
        string value = DataBinder.Eval(item.DataItem, "ShipCountry").ToString();
        string time = DateTime.Now.ToLongTimeString();

        string message = string.Format("Delete record <b>{0}</b> from <b>{1}</b> - {2}?",
                dataKeyID, value, time);
        //button.Attributes.Add("onclick", string.Format("if(!$find('{0}').confirm('{1}', event, 'Delete Record'))return false;",
        //    item.OwnerTableView.OwnerGrid.ClientID, message));
        button.Attributes["onclick"] = "if(!deleteConfirmation('RadGrid1', event, 'Delete Record')) return false;";
    }
}

<script type="text/javascript">
    function deleteConfirmation(gridClientId, ev, originalMessage) {
        var grid = $find(gridClientId)
        var customMessage = "Do you want to delete??!?!";
        return grid.confirm(customMessage, ev, gridClientId, 'Delete Record');
    }
</script>

Regards,
Peter Milchev
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Tags
Grid
Asked by
Mansour
Top achievements
Rank 1
Answers by
Mansour
Top achievements
Rank 1
Eyup
Telerik team
David
Top achievements
Rank 1
Peter Milchev
Telerik team
Share this question
or