[CLOSED] msg.Alert() not working

  1. #1

    [CLOSED] msg.Alert() not working

    I have controller code:

    public ActionResult SaveGridDataChanges(StoreDataHandler handler, int gridID)
     {
                ChangeRecords<Object> rows = handler.BatchObjectData<Object>();
                
                try
               {
                ...
                }
    }
    catch (Exception e)
    {
       X.Msg.Alert("Error:", e.Message).Show();
    // X.Msg.Notify("Error:", e.Message).Show();
    }
    return this.Direct()
    }
    not sure why is Notify() works but Alert() display no message ?
    Thanks
    -susan
    Last edited by Daniil; Sep 05, 2014 at 4:43 AM. Reason: [CLOSED]
  2. #2
    The code you have posted appears to be correct.

    Please ensure you wrap all code samples in [CODE] tags.

    The Forum Guidelines provide tips on posting in the forums:

    http://forums.ext.net/showthread.php?10205-More-Information-Required
    Geoffrey McGill
    Founder
  3. #3
    [Code] tag added to prev request. still not working. I switched to use global error handling as below. the onAjaxException() never been called. Could you help spot any API error? what is good way to debug this ?
    Thanks
    -susanz
    
    @(Html.X().ResourceManager()
        //.ShowWarningOnAjaxFailure (false)
        .Listeners(l =>
              {
                  l.AjaxRequestException.Handler = "onAjaxException";
              })
    )
    
     <script>
     var onAjaxException = function (response, result, el, eventType, action, extraParams, o) {
                alert("Ajex exception called=" + eventType)
                if (eventType === 'event') {
                    //ajax event already has its own error handler
                    return;
                }
    
                Ext.Msg.alert('Error', result.errorMessage);
    
                // return false will stop event from bubbling
                return false;
            }
        </script>
    
      //direct event
            public ActionResult SaveGridDataChanges(StoreDataHandler handler, int gridID)
            {
                ChangeRecords<Object> rows = handler.BatchObjectData<Object>();
      
                try
                {          
                 throw new Exception(" test error"); 
                   
                }
                catch (Exception e)
                {
                    //CPMAppUtil.LogError ("Error SaveCubeDataBulk gridid= " + gridID, e);
                    ResourceManager.AjaxSuccess = false;
                    ResourceManager.AjaxErrorMessage = "Data has no change";// not show
                    throw e;
                }
              
                return this.Direct();
            }
  4. #4
    As for the original post.

    Both, X.Msg.Alert and X.Msg.Notify don't appear for me. It happens because a sync request doesn't executed a response JavaScript code automatically.

    As for global handling. Yes, it is possible, but it might be a bit problematic to extract an error message.

    I would recommend this approach.

    View
    @{
        var X = Html.X(); 
    }
    
    <!DOCTYPE html>
    <html>
    <head>
        <title>Ext.Net.MVC v2 Example</title>
    
        <script>
            var onStoreException = function (propxy, response, operation) {
                var message = operation.getError();
    
                Ext.net.Notification.show({
                    iconCls: 'icon-exclamation',
                    html: message,
                    title: 'EXCEPTION',
                    hideDelay: 5000,
                });
            };
        </script>
    </head>
    <body>
        @X.ResourceManager()
    
        @(X.Store()
            .ID("Store1")
            .Model(X.Model().Fields("test"))
            .Proxy(X.AjaxProxy()
                .API(action =>
                {
                    action.Read = "GetData";
                    action.Sync = "Sync";
                })
                .Reader(X.JsonReader().MessageProperty("message"))
            )
            .ShowWarningOnFailure(false)
            .Listeners(events =>
            {
                events.Exception.Fn = "onStoreException";
            })
        )
    
        @X.Button().Text("Sync").Handler("App.Store1.getAt(0).set('test','new value'); App.Store1.sync({});")
    </body>
    </html>
    Controller
    public ActionResult Index()
    {
        return View();
    }
    
    public ActionResult GetData()
    {
        return this.Store(new object[] 
        { 
            new 
            { 
                test = "Hello" 
            } 
        });
    }
    
    public ActionResult Sync(StoreDataHandler handler)
    {
        try
        {
            throw new Exception("Some Error");
        }
        catch(Exception e)
        {
            return this.Store(e.Message);
        }
    
        return this.Store(new object[] {});
    }
  5. #5
    Great! That works.
    Thanks
    -susanz

Similar Threads

  1. [CLOSED] Alert box
    By Sowjanya in forum 2.x Legacy Premium Help
    Replies: 1
    Last Post: Aug 02, 2013, 12:29 AM
  2. Need Help : MessageBox setIcon() not working on Alert()
    By santhu12smart in forum 1.x Help
    Replies: 6
    Last Post: Dec 09, 2011, 12:10 PM
  3. alert vs Ext.Msg.alert + window.location
    By Nime in forum 1.x Help
    Replies: 0
    Last Post: Nov 10, 2009, 3:34 AM
  4. [CLOSED] Hi , Ext.Msg.alert?
    By Satyanarayana murthy in forum 1.x Legacy Premium Help
    Replies: 9
    Last Post: May 11, 2009, 2:47 PM
  5. Message alert in the .cs
    By flaviodamaia in forum 1.x Help
    Replies: 4
    Last Post: Jan 21, 2009, 2:53 PM

Posting Permissions