我想顯示默認圖像,如果圖像字段爲空。這是我的圖像字段代碼。如果圖像字段在劍道網格中爲空,如何顯示默認圖像?
{ field: "Photo",
title: "Photo",
template: '<img src="#= Photo #" alt="image" width="80px" height="80px" />',
width: 100
}
我想顯示默認圖像,如果圖像字段爲空。這是我的圖像字段代碼。如果圖像字段在劍道網格中爲空,如何顯示默認圖像?
{ field: "Photo",
title: "Photo",
template: '<img src="#= Photo #" alt="image" width="80px" height="80px" />',
width: 100
}
試試這個
{
field: "Photo",
title: "Photo",
template: function(dataItem) {
return kendo.template(
'<img src="#= Photo #" alt="image" width="80px" height="80px" />'
)({Photo: dataItem.Photo || 'http://path-to-image'});
}
width: 100
}
這dataItem.Proto || 'http://path-to-image'
意味着如果Photo
是falsy(null
,false
,0
,''
,undefined
),然後使用默認路徑
簡單!
{
field: "Photo",
title: "Photo",
template: '<img src="#= Photo == null ? "http://exemple.com/pic.jpg" : Photo #" alt="image" width="80px" height="80px" />',
width: 100
}
這是可能與kendo listview的PHP。由於我設置了默認圖像,但它不起作用。 – 2017-02-10 14:07:44
對不起,對於延遲reply.It工作:) @Alexander – Ironman 2015-02-11 15:01:45