JqGrid inline editing integration with DJango send csrf token


Here is a quick snippet to send csrf_token in POST data from inline edit JqGrid to Django:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
var tableGrid = $(selector).jqGrid({
   ….
   onSelectRow: function(id){
         if(id && id!==lastSel){
            $(selector).restoreRow(lastSel);
            lastSel=id;
         }

         var editparameters = {
            extraparam: {csrfmiddlewaretoken: $(‘.token-data’).data(‘token’)},
            keys: true,
          };
         $(selector).jqGrid(‘editRow’, id, editparameters);

    }
};

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.