Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed the column value is undefined when the row data is a nested json #256

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 18 additions & 4 deletions src/internal.js
Original file line number Diff line number Diff line change
Expand Up @@ -611,10 +611,24 @@ function renderRows(rows)
{
if (column.visible)
{
var value = ($.isFunction(column.formatter)) ?
column.formatter.call(that, column, row) :
column.converter.to(row[column.id]),
cssClass = (column.cssClass.length > 0) ? " " + column.cssClass : "";
var value = "";
if($.isFunction(column.formatter)){
value = column.formatter.call(that, column, row);
}else{
// 解决JSON嵌套取值为undefinded问题
var columnId = column.id;
if(columnId.indexOf(".")){
var columnIds = columnId.split(".");
$.each(columnIds, function(index, id){
value = (index===0) ? row[id] : value[id];
})
}else{
value = row[column.id];
}
column.converter.to(value);
}

var cssClass = (column.cssClass.length > 0) ? " " + column.cssClass : "";
cells += tpl.cell.resolve(getParams.call(that, {
content: (value == null || value === "") ? " " : value,
css: ((column.align === "right") ? css.right : (column.align === "center") ?
Expand Down