1

我的编辑器数据表有问题。我无法将 Editor DataTable“创建新条目”表单值传递给我的 python 文件。我不知道做错了什么或我错过了什么。这是我的脚本部分:

var editor;
var oTable;
function getStudentdetails(id) {
    editor = new $.fn.dataTable.Editor({  
       ajaxUrl: {
             "create":  "/addStudentdetails",
              "edit":   "/editStudentdetails",
              "remove": "/deleteStudentdetails"
               },
       dom: "Tfrtip",
       table: "#table_student_details",   
       fields: [ {
              label: "Id:",
              name: "id",
              attr:  {
                 maxlength: 50,
                 name:"id",
                 placeholder: 'ID'
                    }
              }, {
            label: "Name:",
            name: "name"
            }
          ]  
        });

   oTable = $('#table_student_details').DataTable({
       dom: "Tfrtip",
       destroy: true,
       ajax: {
           "url": url_prefix + "/getStudentDetails",
           "data": function(d) {
                d.id = id;
            }
         },
       tableTools: {
          sRowSelect: "os",
          aButtons: [{
            sExtends: "editor_create",
            editor: editor
            }, {
            sExtends: "editor_edit",
            editor: editor
            }, {
            sExtends: "editor_remove",
            editor: editor
          }]
     }
 });
}

当我尝试从创建新条目表单存储新记录时,我在 python 文件中什么也没有。

Python 文件。

def addStudentDetails(self, form=None):
    if not form:
        form = self.request.form
    handler = self.getDBHandler()
    values = {}
    id = form.get('id')
    name = form.get('name') 
    print "ID:",id // it gives ID: None    
    print "NAME:",name // it gives NAME: None

我不知道为什么我不能在我的 python 文件中获取 Create New Entry Form 值。提前致谢。

4

0 回答 0