Ajax call in ColumnDefs

Ajax call in ColumnDefs

Godrules500Godrules500 Posts: 25Questions: 13Answers: 0

Is there a way to do an ajax call in the ColumnDefs?

So the circumstance that I am in, I pass an ID to the view, then I need to, when it is rendering the value, do an ajax call so that I can get the description that belongs to the ID, so that I can display it as well.

Is this possible?

Answers

  • jrbulnesjrbulnes Posts: 5Questions: 0Answers: 0

    Yes it is. I did it by calling a function that sets a global variable. In the function you do your second or other Ajax Call

    { "mData": null,
      "render": function ( data, type, full) {
        getDescription(data.ID);    // calling function to get Description
    
        if (typeof Description !== 'undefined') {
           return Description;
        }   
        else {
                return '-';
        }
      }
    },
    
  • Godrules500Godrules500 Posts: 25Questions: 13Answers: 0

    That doesn't work for me unfortunately. Description is still undefined because render finishes before the ajax call is called.

    Any other ideas?

    I'm using an MVC 5 application

This discussion has been closed.