开发者

How to show message after deleting row in devexpress aspxdatagridview?

开发者 https://www.devze.com 2023-03-25 10:53 出处:网络
I have ASPxGridView from Devexpress and I want to show message after clicking the delete button, this message could be html div containing text or java script alert message.

I have ASPxGridView from Devexpress and I want to show message after clicking the delete button, this message could be html div containing text or java script alert message.

Any idea how could this achieved ?

I'm trying this but it's not working:

    protected void ASPxGridViewCategories_RowDeleting(object sender, DevExpress.Web.Data.ASPxDataDeletingEventArgs e)
    {
        try
 开发者_运维技巧       {
            Response.write("<script>alert('my message');</script>");                
        }
        catch (Exception ex)
        {
        }
    }


Using bunch of properties ASPxGridView.JSProperties + ASPxClientGridView.EndCallback you can do it - please see example: ASPxGridView - Client-Side RowInserted Notification.


[JScript] In aspx

  function OnEndCallback(s,e)
    {
         if (s.cpAlertMessage != null)
          {
               alert(s.cpAlertMessage);
          }
   }

[VB.Net]

    Protected Sub ASPxGridView1_RowDeleting(ByVal sender As Object, ByVal e As DevExpress.Web.Data.ASPxDataDeletingEventArgs) Handles ASPxGridView1.RowDeleting

     CType(sender, ASPxGridView).JSProperties("cpAlertMessage") = "Your Custom Alert!!"
e.Cancel = True

End Sub


You could access the style information for a div and set it visible.


It is possible to show custom messages in the aspxgridview:

In the properties box, go to Settings Text, look for title, here you can add a title for the grid. In your code, when you want to show any message, after any event, this include: not deleting, inserting, deleting, updating, add this code:

ASPxGridView1.Settings.ShowTitlePanel = True ASPxGridView1.SettingsText.Title = "CHANGES ARE DONE"

You don't need to show any alert messages from javascript, or using the JSProperties method, since this is done before the callback finishes.


You really want to add a ClientSideEvent for handling the EndCallback event. Then you can have a JavaScript function which sets the property on the grid, though we usually just have an ASPxLabel with ClientVisible = False when the page is loaded, and set the ClientVisible to true in the JavaScript.

function grid_BeginCallback(s, e) {
    // Whenever a callback starts, hide the result label.
    lbl.SetclientVisible(false);
}

function grid_EndCallback(s, e) {
    lbl.SetText("CHANGES ARE DONE");
    lbl.SetclientVisible(true);
}

This support message describes how you would do this pretty well:

ASPxGridView - How to execute javascript after callback is completed

0

精彩评论

暂无评论...
验证码 换一张
取 消