Search code examples
jqueryajaxasp.net-ajaxsyncfusion

Make method asynchronius in ajax success section


I have the following ajax script.

$.ajax({
  url: url,
  type: "DELETE",
  dataType: "text",
  success: function (data) {
    var grid = $('#rolesgrid').ejGrid("instance");
    grid.refreshContent();
    $('#rolesgrid_delete').css('visibility', 'hidden');
    renameConditionType(grid);     
  },
  error: function (xhr, textStatus, errorThrown) {
    showDialogMessage('Page error', errorThrown, 'danger');
  }  
});

When I make request by calling function grid.refreshContent(). The next function renameConditionType(grid) is called. This second change context of specific column.

When request from function grid.refreshContent() is finished. It overwrites the result of function renameConditionType(grid).

How to make in order to wait when request from function grid.refreshContent(). I use syncfusion javascript grid.


Solution

  • When we use refreshContent method the actionComplete event of ejGrid will be triggered. In this event you can check the requestType as refresh using the arguments to achieve your requirement.

    Please refer the below documentation for the details of the actionComplete event and refreshContent method.

    https://help.syncfusion.com/api/js/ejgrid#events:actioncomplete

    https://help.syncfusion.com/api/js/ejgrid#methods:refreshcontent

    If you still face any complexities please get back to me with the following details.

    1. In the renameconditiontype() function are you changing the column name or the dataSource of the column.
    2. Do you need the result of the renameconditiontype() method to be maintained after gridRefreshContent() method is called.
    3. Share the grid code example.