我有一个包含远程服务器数据(jquery)的kendo网格。除了过滤日期列之外,其他一切都正常。
我试图找到到达服务器的内容,因为错误表明它缺少一些索引,因此对象的外观如下:
stdClass Object
(
[callback] => jQuery33109464971368584616_1563872509336
[take] => 20
[skip] => 0
[page] => 1
[pageSize] => 20
[filter] => stdClass Object
(
[logic] => and
[filters] => Array
(
[0] => stdClass Object
(
[field] => oDate
[operator] => gt
[value] => Wed Jul 03 2019 00:00:00 GMT+0200 (Mitteleuropäische Sommerzeit)
)
)
)
[_] => 1563872509340
)
如您所见,操作员会收到“ oDate”字段,因此我认为在客户端就可以了。
这是我的剑道网格:
$("#mainSupportgrid").kendoGrid({
dataSource: {
pageSize: 20,
serverFiltering: true,
serverPaging: true,
serverSorting: true,
sort: { field: "oDate", dir: "desc" },
reorderable: true,
transport: {
read: {
url:"http://server1/API/ticketing/list2/",
dataType: "jsonp",
contentType: "application/json; charset=utf-8"
}
},
schema: {
data: "data",
total: "total",
model: {
fields: {
cID: { type: "number" },
tID: { type: "number" },
tTitle: { type: "string" },
oDate: { type: "date" },
tState: { type: "string" },
tPriority: { type: "string" },
tCreator: { type: "number" },
tSupporter: { type: "number" },
tKeywords: { type: "string" },
tInovice: { type: "string" }
}
}
}
},
filterable: true,
sortable: true,
selectable: true,
pageable: true,
columns: [{
field:"tID",
title:"TID",
width:"50px"
},{
field:"cName",
title:"Kunde",
width:"150px",
filterable: false,
sortable: false
},{
field: "tTitle",
title: "Titel",
filterable: {
operators: {
string: {
contains: "Enthält",
eq: "Ist gleich",
neq: "Ist ungleich",
startswith: "Beginnt mit",
endswith: "Endet mit",
isempty: "Ist leer",
isnotempty: "Ist nicht leer"
}
}
}
}, {
field: "oDate",
title: "Erstellt",
format: "{0:dd.MM.yyyy HH:mm}",
width: "130px",
filterable: {
operators: {
date: {
gt: "Nach",
lt: "Vor"
}
}
}
}, {
field: "tState",
title: "Status",
width: "130px",
template: "#= getTicketState(tState) #",
filterable: {
extra: false,
ui: ticketStateFilter,
operators: {
string: {
eq: "Ticket ist",
neq: "Ticket ist nicht"
}
}
}
}, {
field: "tPriority",
title: "Priorität",
width: "100px",
template: '#= template_tPriority(tPriority)#',
filterable: {
ui: ticketPriorityFilter,
operators: {
string: {eq: "Priorität ist", neq: "Priorität ist nicht"}
}
}
}, {
field: "tCreator",
title: "Eröffnet von",
width: "120px",
template: "#= getUserName(tCreator) #",
filterable: {
extra: false,
ui: userFilter,
operators: {
string: {eq: "Mitarbeiter ist", neq: "Mitarbeiter ist nicht"}
}
}
}, {
field: "tSupporter",
title: "Zugewiesen",
width: "120px",
template: "#= getUserName(tSupporter) #",
filterable: {
extra: false,
ui: userFilter,
operators: {
string: {eq: "Mitarbeiter ist", neq: "Mitarbeiter ist nicht"}
}
}
}, {
field: "tKeywords",
title: "Suchbegriffe",
width: "120px",
filterable: {
operators: {
string: {
contains: "Enthält",
eq: "Ist gleich",
neq: "Ist ungleich",
startswith: "Beginnt mit",
endswith: "Endet mit",
isempty: "Ist leer",
isnotempty: "Ist nicht leer"
}
}
}
}, {
field: "tInvoice",
title: "Rechnung",
template: "#if(tInvoice == 0){# Offen #}else{# #=tInvoice # #}#",
width: "90px",
filterable: {
extra: false,
ui: ticketInvoiceFilter,
operators: {
string: {eq: "Rechnung ist", neq: "Rechnung ist nicht"}
}
}
}],
change: function(e){
var selectedItem = this.dataItem(this.select());
// Add tab
var tabStrip = $("#mainNavigation").data("kendoTabStrip");
var tabToActivate = $("#t"+selectedItem.tID).closest('.k-item');
if(tabToActivate.length){
tabStrip.select(tabToActivate);
}else{
tabStrip.append({ text: "<span id='t"+selectedItem.tID+"'/><span class=\'k-icon k-i-file\' span></span>Ticket: #" + selectedItem.tID + '<img class="tabCloseButton" src=\'jar/images/tabStripClose.png\' onclick=\'jar_close(this)\' />', encoded: false, content: "Lade Ticket" });
tabStrip.select((tabStrip.tabGroup.children("li").length - 1));
var lastIndex = tabStrip.tabGroup.children().length - 1;
var tabContent = $(tabStrip.contentElement(lastIndex));
// Load the content of the new tab
var tabLoader = new kendo.data.DataSource({
transport: {
read: {
url: "http://server1/api/tabLoad/ticketing/id/" + selectedItem.tID
}
},
requestEnd: function(e){
tabContent.html(e.response)
}
})
// load the stuff
tabLoader.read()
}
}
});
在服务器端,我有以下代码:
if ($_SERVER['REQUEST_METHOD'] == 'GET') {
header('Content-Type: application/json');
$result = new DataSourceResult('mysql:host=127.0.0.1;dbname=test','test','********',array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8'));
$object = json_decode(json_encode($_GET), FALSE);
$customer = new customer();
$columns = array('cID', 'dID', 'tID', 'tTitle', 'tDesc', 'oDate', 'cDate', 'tState', 'tPriority', 'tKeywords', 'tCreator', 'tSupporter','tInvoice');
$result = $result->read('jar_ticketing_index', $columns, $object);
for ($index = 0, $count = count($result['data']); $index < $count; $index++) {
// Get Customer Name
$customer->getCustomerInfo($result['data'][$index]['cID']);
if($customer->info['Kostenstelle'] == '100'){
$result['data'][$index]['cName'] = $customer->info['Firma'];
}else{
$result['data'][$index]['cName'] = $customer->info['Nachname']." ".$customer->info['Vorname'];
}
}
//print_r($result);
echo $_GET['callback']."(".json_encode($result).")";
//echo $_GET['callback']."(".json_encode($result->read('jar_ticketing_index', array('cID', 'dID', 'tID', 'tTitle', 'tDesc', 'oDate', 'cDate', 'tState', 'tPriority', 'tKeywords', 'tCreator', 'tSupporter','tInvoice'), $object)).")";
}
我从DataSorurceResult.class.php收到php错误
Undefined index: gt in <b>C:\API\classes\DataSourceResult.class.php</b> on line <b>282
(例如“大于”,但在所有情况下均失败)