JS网格未在表中显示数据

时间:2019-03-07 17:23:20

标签: jsgrid

由于许可问题,我不得不将我在Filemaker上开发的几乎完成的项目更改为Open Source。所以我必须在编程时学习PHP,Javascript和所有其他东西。我正在为这个问题奋斗2周。我的JS Grid表格中有一个php文件,该文件也可见:

我在表格中的代码

$(document).ready(function() {
$('#contacts_table').jsGrid({

    width: "100%",
    height: "457px",

    pageLoading: false,
    filtering: true,
    inserting: true,
    editing: true,
    sorting: true,
    paging: true,
    autoload: true,
    pageSize: 10,
    pageButtonCount: 2,
    confirmDeleting: true,
    noDataContent: "Not found",

    deleteConfirm: "Do you really want to delete data?",

    controller: {

        loadData: function (filter) {
            return $.ajax({
                type: "GET",
                url: "fetch_contacts_supplier_JS_Grid.php",
                data: filter,
                dataType: "json"
            });
        },
    },

    fields: [
        {name: "Id",        type: "number",     width: 10,  visible: false},
        {name: "SupplierId",type: "number",     width: 10,  visible: false},
        {name: "Title",     type: "text",       width: 10,  validate: "required"},
        {name: "Name",      type: "text",       width: 30,  validate: "required"},
        {name: "Surname",   type: "text",       width: 30,  validate: "required"},
        {name: "Position",  type: "text",       width: 20,  validate: "required"},
        {name: "Phone",     type: "text",       width: 30},
        {name: "Mobile",    type: "text",       width: 30},
        {name: "Fax",       type: "text",       width: 30},
        {name: "Email",     type: "text",       width: 30},
        {name: "Active",    type: "checkbox",   width: 10,  validate: "required"},
        {                   type: "control",    width: 10}
    ]

});
});

我的数据库选择代码(有效)fetch_contacts_supplier_JS_Grid.php:

 if($method == 'GET') {
    If ($statement = $link->prepare("SELECT * FROM suppliers_contacts WHERE _fk_SuppliersID = 1")) {
        if ($statement->execute()) {
            $result = $statement->get_result(); // fetchAll(PDO::FETCH_ASSOC);
            while($row = $result->fetch_assoc()) {
                $new_array[] = array(
                    'Id' => $row['_pk_SuppliersContactsID'],
                    'SupplierId' => $row['_fk_SuppliersID'],
                    'Title' => $row['Title'],
                    'Name' => $row['Name'],
                    'Surname' => $row['Surname'],
                    'Position' => $row['Job_Position'],
                    'Phone' => $row['PhoneFixed'],
                    'Mobile' => $row['PhoneCell'],
                    'Fax' => $row['PhoneFax'],
                    'Email' => $row['Email'],
                    'Active' => $row['Active']
                );
            }
        }
        header("Content-Type: application/json");
        echo json_encode($new_array);
    } ELSE {
        echo $link->error;
    }
 }

我在控制台中得到的数组:

  

[{“ Id”:1,“ SupplierId”:1,“ Title”:“ Mr。”,“ Name”:“ Jens”,“ Surname”:“ Dietzel”,“ Position”:“ Owner”, “ Phone”:“ 145754”,“ Mobile”:“ 86868”,“ Fax”:“ 4368843”,“ Email”:“ jens@jd-sd.com.na”,“ Active”:“ checked”},{ “ Id”:2,“ SupplierId”:1,“ Title”:“ Mrs。”,“ Name”:“ Karen”,“ Surname”:“ Mann”,“ Position”:“ Manager”,“ Phone”:“ 24525“,”移动“:” 745754“,”传真“:” 544“,”电子邮件“:” karen@test.de“,”活动“:”已选中“}]

但是表显示not found。我在做什么错了?

0 个答案:

没有答案