Skip to content Skip to sidebar Skip to footer

Performing Action A Button Click Event, Button Being Placed Inside Dojox.grid.datagrid.

I have a dojox.grid.DataGrid. In this a set of values are being displayed along with last 2 columns being filled up with buttons which are created dynamically according to data bei

Solution 1:

I think, what you need is adjusting your server-side code to handle ajax post requests for sending mail and use dojo.xhrPost method when user clicks button. Your JS code may look like this:

functionsendMailHandler(evt, item) {
    dojo.xhrPost({
      url: "/2_8_2012/jsp/SendMailReminder.jsp",
      content: {
        'SendMail': item
      },
      error: function() {
        alert("Sent failure");
      },
      load: function(result) {
        alert("Email sent with result: " + result);
      }
    });

    dojo.stopEvent(evt);
  }

  functionsendmail(item) {
    return"<button onclick='sendMailHandler(arguments[0], \"" + item +  "\")'>Send Mail</button>";
  }

Note that dojo.stopEvent(evt); in sendMailHandler is used to stop event bubbling and prevents RowClick raising.

There is also dojo.xhrGet with similar syntax to perform ajax GET requests, which you can use instead of jQuery's $.get. You can also use dojo.xhrGet instead of dojo.xhrPost in my example, because there is chance that it will work with your back-end without tweaking, but POST (or ajax form submission) would be more semantically correct.

And about "Tried to register an id="something", you should adjust your code to avoid IDs duplication. Or show your code causing errors.

Post a Comment for "Performing Action A Button Click Event, Button Being Placed Inside Dojox.grid.datagrid."