Editor ajax override

Editor ajax override

mark4284mark4284 Posts: 5Questions: 1Answers: 0

So, I was wondering if there's a way for me to override the data format being passed from client to server?
At the moment I'm using django as the back-end and currently the format is:

<QueryDict: {u'action': [u'edit'], u'data[12][name]': [u'Bartell, Anderson and Macejkovicasdf']}>

I'm assuming datatables is auto assigning a key of data with an array where each item has a key of id and value of the values itself. I want it to be key of 'data' with an array of dictionaries

This is bad b/c in order for me to iterate through, I'd need to string parse instead of using built ins like so:

#params:
#fetches data[12] of param name
request.PUT.getlist('data[12][name]')

I want it such that the format is in this way:

  {
    'action' : 'edit',
    'data' : [
      {
          'id' : ___,
          'name' : ___,
      },
      {
        ...
      },
      ...
    ] 

This way, I can access the data as such:
```
request.PUT.getlist('data[]') and this will output me an array of dictionaries

Replies

  • mark4284mark4284 Posts: 5Questions: 1Answers: 0

    I realized there was an event: 'preSubmit',
    How do I close this discussion?

  • allanallan Posts: 63,771Questions: 1Answers: 10,510 Site admin

    You are correct - in Editor preSubmit is the way to do it.

    "Discussions" (as opposed to "Questions") can't be closed. But anyone reading this will realised it has been resolved!

    Allan

This discussion has been closed.