Wednesday 11 April 2012

Datatables update function shows an Alert Box

When using the jQuery Datatable plugin and jeditable to allow tables to be editable, calling the update function via sUpdateUrl shows an alert box on it's return.
To suppress the alert box, return the same value that was originally passed in.
C# MVC Example:
$('#myDataTable').dataTable().makeEditable({
    sUpdateURL: "/Home/UpdateData"
})

public class HomeController : Controller
{
    public string UpdateData(int id, string value,
                             int? rowId, int? columnPosition,
                             int? columnId, string columnName)
    {
        //Add code to update cell
        return value;
    }
}
Code borrowed from http://code.google.com/p/jquery-datatables-editable/wiki/EditCell

No comments: