JsGrid中的JSON在页面加载时不显示JsGrid中的数据。没有错误,但是数据在JsGrid中。我需要搜索一些内容,然后显示日期

时间:2018-10-17 10:22:16

标签: php json laravel jsgrid

我确实在apache上运行我的代码。在PHP中一切正常。但不是在阿帕奇。我需要过滤一些东西,然后数据显示出来。在此之前,数据在那里但没有显示。可以帮忙?

这是我的ajax电话。

db.call = 
$.ajax({
contentType: "application/json; charset=utf-8",
url: userapi,
datatype: "json",
success:function(data) {
    var parsed = JSON.parse(data);
    for(var i in parsed)
    {
        db.clients.push(parsed[i]);
    }
}});

这是我的jsgrid

$("#userlist").jsGrid({
width: "100%",
autoload: true,
confirmDeleting: true,
paging: true,
selecting: false,
filtering: true,
pageSize: 15,
pageButtonCount: 5,
controller: db,
fields: [
    {
        headerTemplate: function(_, item) {
            return $("<input>").attr("type", "checkbox")
                    .on("change", function (){
                    $(this).is(":checked") ? selectAll(item) : unselectAll(item);
                    });
        },
        itemTemplate: function(_, item) {
            return $("<input name='save_value' class='chk' id='save_value' onChange='getValueUsingClass();'>").attr("type", "checkbox")
                    .val("" + item.id)
                    .prop("checked", $.inArray(item, selectedItems) > -1)
                    .on("change", function () {
                        $(this).is(":checked") ? selectItem(item) : unselectItem(item);
                    });
        },
        align: "center",
        width: 20,
    },
    { name: "id", title: "Id", type: "number", width: 25, align: 'center' },
    { name: "name", title: "Name",
        itemTemplate: function(_, item) {
                        urldisplay = gurldisplay;
                        urldisplay = urldisplay.replace('id', item.id);
                        return $('<a href='+urldisplay+'>').text(item.name);
                    },
        type: "text", width: 70 },
    { name: "email", title: "Email", type: "text", width: 200 },
    { name: "created_at", title: "Created At", type: "date", width: 50 },
    { name: "updated_at", title: "Updated At", type: "date", width: 50 },
    { type: "control",
        itemTemplate: function(_, item) {
            var urledit = gurledit;
            urledit = urledit.replace('id', item.id);
            return $("<form action='"+formactionurl+"' method='POST'><input type='hidden' name='_token' value='" + document.getElementsByName('_token')[0].value + "'><div class='btn-group' role='group'><a href="+urledit+" class='btn btn-icon btn-primary btn-round btn-sm' id='edit' name='edit'><i class='icon-edit'></i></a></div></form>");
        }, 
        editButton: false, deleteButton: false }]});

这是我的负载数据

var db = {loadData: function(filter) {
            return $.grep(this.clients, function(client) {
                return (!filter.id || client.id === filter.id)
                    && (!filter.name.toLowerCase() || client.name.toLowerCase().indexOf(filter.name.toLowerCase()) > -1)
                    && (!filter.email.toLowerCase() || client.email.toLowerCase().indexOf(filter.email.toLowerCase()) > -1)
                    && (!filter.created_at.from || new Date(client.created_at) >= filter.created_at.from) 
                && (!filter.created_at.to || new Date(client.created_at) <= filter.created_at.to .setDate(filter.created_at.to.getDate() + 1))
                && (!filter.updated_at.from || new Date(client.updated_at) >= filter.updated_at.from) 
                && (!filter.updated_at.to || new Date(client.updated_at) <= filter.updated_at.to .setDate(filter.updated_at.to.getDate() + 1));
            });
        },

    insertItem: function(insertingClient) {
        this.clients.push(insertingClient);
    },

    updateItem: function(updatingClient) { },

    deleteItem: function(deletingClient) {
        var clientIndex = $.inArray(deletingClient, this.clients);
        this.clients.splice(clientIndex, 1);}};

这是图片https://imgur.com/a/vL2SSkP

0 个答案:

没有答案