Home > front end >  About Layui data parsing
About Layui data parsing

Time:09-17

I'm using Layui data parsing, because the returned data field is not consistent with the header, so want to use parseData parsed into the format of the table contents, but the data returned, but the back of the point not to come out, how to do? Use version is 2.5.5 Layui

Table. The render ({
Elem: '# test'
, the url: CCSHmobi. Website + "TaskPublishing/GetDeveloper
", the toolbar: '# toolbarDemo'//open the head toolbar, and binding on the left side of the template
, defaultToolbar: [' filter ', 'exports',' print ']
Title: 'to-do list'
, cols: [[
{field: "id", the title: "id", width: 80, fixed: 'left' unresize: true, sort: true}
, {field: "WorkName", the title: 'task name, edit:' text '}
, {field: 'PublisherName', the title: 'publisher' edit: 'text, sort: true}
, {fixed: 'WorkTime, title:' release time, edit: 'text, sort: true}
, {
Field: 'WorkingCondition, title:' task status, sort: true, templet: function (res) {
If (res) WorkingCondition=="2") {
Return '& lt; Em> Ongoing & lt;/em> '
}
}
}
, {fixed: 'right' and the title: 'operation, the toolbar:' # barDemo '}
]]
, page: true
Response: {
StatusCode: 200//a status code of success, the default: 0
}
ParseData: function (res) {//parsed into the original data table component of data
Alert (res)
Return {
"Code" : res. Status,//interface state
"MSG" : res. Analytical tooltip text message,//
"Count" : res. Total, analytical data length//
"Data" : res. Analytical data. The data item//list
};
}
});
The data returned: {{" WorkName ":" test ", "PublisherName" : "test", "ExecutorName" : "test", "Woketime" : "2020/05/01", "Endtime" : null, "WorkingCondition" : "2", "Description" : "test", "type" : 0}]}

CodePudding user response:

Errors are always read the property 'item' of undefined

CodePudding user response:

I already know the problem, I made stupid, wrong format emm
  • Related