Skip to content

Commit 7988ca2

Browse files
committed
further changes to formatter type recognition as per issue #123. also change type recognition in canCellBeActive and canCellBeSelected to cast other types to a boolean
1 parent 4e49d56 commit 7988ca2

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

slick.grid.js

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1714,7 +1714,7 @@ if (typeof Slick === "undefined") {
17141714

17151715
// if there is a corresponding row (if not, this is the Add New row or this data hasn't been loaded yet)
17161716
if (item) {
1717-
stringArray.push(typeof formatterResult !== 'object' ? formatterResult : formatterResult.text);
1717+
stringArray.push(Object.prototype.toString.call(formatterResult) !== '[object Object]' ? formatterResult : formatterResult.text);
17181718
}
17191719

17201720
stringArray.push("</div>");
@@ -1833,7 +1833,7 @@ if (typeof Slick === "undefined") {
18331833
}
18341834

18351835
function applyFormatResultToCellNode(formatterResult, cellNode, suppressRemove) {
1836-
if (typeof formatterResult !== 'object') {
1836+
if (Object.prototype.toString.call(formatterResult) !== '[object Object]') {
18371837
cellNode.innerHTML = formatterResult;
18381838
return;
18391839
}
@@ -3527,19 +3527,19 @@ if (typeof Slick === "undefined") {
35273527
}
35283528

35293529
var rowMetadata = data.getItemMetadata && data.getItemMetadata(row);
3530-
if (rowMetadata && typeof rowMetadata.focusable === "boolean") {
3531-
return rowMetadata.focusable;
3530+
if (rowMetadata && typeof rowMetadata.focusable !== "undefined") {
3531+
return !!rowMetadata.focusable;
35323532
}
35333533

35343534
var columnMetadata = rowMetadata && rowMetadata.columns;
3535-
if (columnMetadata && columnMetadata[columns[cell].id] && typeof columnMetadata[columns[cell].id].focusable === "boolean") {
3536-
return columnMetadata[columns[cell].id].focusable;
3535+
if (columnMetadata && columnMetadata[columns[cell].id] && typeof columnMetadata[columns[cell].id].focusable !== "undefined") {
3536+
return !!columnMetadata[columns[cell].id].focusable;
35373537
}
3538-
if (columnMetadata && columnMetadata[cell] && typeof columnMetadata[cell].focusable === "boolean") {
3539-
return columnMetadata[cell].focusable;
3538+
if (columnMetadata && columnMetadata[cell] && typeof columnMetadata[cell].focusable !== "undefined") {
3539+
return !!columnMetadata[cell].focusable;
35403540
}
35413541

3542-
return columns[cell].focusable;
3542+
return !!columns[cell].focusable;
35433543
}
35443544

35453545
function canCellBeSelected(row, cell) {
@@ -3548,16 +3548,16 @@ if (typeof Slick === "undefined") {
35483548
}
35493549

35503550
var rowMetadata = data.getItemMetadata && data.getItemMetadata(row);
3551-
if (rowMetadata && typeof rowMetadata.selectable === "boolean") {
3552-
return rowMetadata.selectable;
3551+
if (rowMetadata && typeof rowMetadata.selectable !== "undefined") {
3552+
return !!rowMetadata.selectable;
35533553
}
35543554

35553555
var columnMetadata = rowMetadata && rowMetadata.columns && (rowMetadata.columns[columns[cell].id] || rowMetadata.columns[cell]);
3556-
if (columnMetadata && typeof columnMetadata.selectable === "boolean") {
3557-
return columnMetadata.selectable;
3556+
if (columnMetadata && typeof columnMetadata.selectable !== "undefined") {
3557+
return !!columnMetadata.selectable;
35583558
}
35593559

3560-
return columns[cell].selectable;
3560+
return !!columns[cell].selectable;
35613561
}
35623562

35633563
function gotoCell(row, cell, forceEdit) {

0 commit comments

Comments
 (0)